I'm a beginner.
I am starting my studies in image processing and I am using the Julia Language.
I have tried until unsuccessfully to develop the Algorithm 1 of this article https://hal.archives-ouvertes.fr/hal-03330433/document, on page 3.
I noticed that there is a similar algorithm proposed in Matlab and in C on this site https://elad.cs.technion.ac.il/software/?pn=1427. The authors provided the algorithm and the article where these ideas were proposed.
I read and studied both, but I could not to do in Julia Language.
The algorithm proposed is
where, the graph G is a pair (V, E), with V the color values {v1, v2, ..., vm} and E the edge eij = (vi, vj).
I think that the constant alpha is 10^6. But I need to read the second paper again.
To show my doubts, I am placing a random RGB color image of size 6 x 5 (30 pixels), putting the color set T as a 3 x 30 matrix and putting the random probability vector as p.
After that I am generating the list L and choose j in L.
julia>
using Colors, FixedPointNumbers
using Images
using Statistics
using LinearAlgebra
img = rand(RGB{N0f8}, 6, 5) # random RGB color image of size 6 x 5
a, b = size(img)
T = reshape(channelview(img), 3, a*b) # matrix T of 3 x 30. Every column is a r, g, b color of img
p = rand(a*b) # random vector p of 30 elements
L = [i for i=1:30] #index list
j = rand(L) #choose a random j in L
#find the pixel (pix_i, pix_j) of the image
if j % a == 0
pix_i = a
pix_j = div(j, a)
else
pix_i = j % a
pix_j = 1 + div(j, a)
end
#The edges eij = (vj, vk)#
for i = pix_i - 1: pix_i+1
for j = pix_j -1 : pix_j + 1
N = CartesianIndex(i, j)
end
end
After that, I don't know how can I continue.
Here in that last line I already have a problem. Because I'm not able to build the set N(vj) with the indices.
In fact, I also don't know how to add to the end the vectors that we get at each iteration.
That is, my problem is in the construction of this set P and so on. Regarding the N(vj) inside of the command "for" that the author proposes, I am considering a 3 x 3 square. So, for example, for a pixel at position (4, 3) in the first iteration (i.e., j = (4,3)), I would have for absolute value of N(vj) is 8, because in the first iteration, we will get the pixels (3, 2), (3,3), (3,4), (4,2), (4,3), (4,4), (5,2), (5,3) and (5,4).
So N(vj) = {(3, 2), (3,3), (3,4), (4,2), (4,3), (4,4), (5,2), (5,3),(5,4)} \ {(4,3)}.
So the absolute value is 8.
But, I can't do it.
If you can help me, I would be very grateful.
