I am attempting to extract the Radon Signature in order to recognize patterns of clothing (striped,plaid, irregular and patternless) as done in 1.
Algorithm to be implemented :
1. Use sobel operator to compute the gradient map as f(x,y).
2. Perform Radon transform based on maximum disk area.
3. Compute the variance of r under all theta directions.
4. Employ L2-norm to normalize the feature vector.
5. Plot Radon Signature as a bar chart of var(r) for all theta values.
I have done the following :
img = imread('plaid.jpg');
grey = rgb2gray(img);
img2 = edge(grey, 'sobel');
vararray=zeros(1,size(theta,2));
theta = -89:90;
for j = 1: size(theta,2)
[R3,xp3] = radon (img2,theta(j));
vararray(j) = var(R3);
end
vararray = vararray/norm(vararray);
figure(1), bar(theta,vararray),title('Radon Signature');
I believe that my error lies in the first 2 steps. I am unsure how to perform Radon only on the maximum disk area.
My results are shown on the right, while from the article (referenced below) is shown on the left.
However, my results should at least show 2 distinct peaks as shown in the acticle's results, but they do not.
Any assistance is appreciated.
Source of Algorithm : "Assistive Clothing Pattern Recognition for Visually Impaired People" by Xiaodong Yang, Student Member, IEEE, Shuai Yuan, and YingLi Tian, Senior Member, IEEE
Maximum disk area is, as @beaker thought, defined by the maximum filled circle that fits inside the bounding box of the image. That you can observe from the Fig.3 b) of the article.
Another thing you did wrong, is using edge detector edge(grey, 'sobel')
while you should use gradient map or more formally gradient magnitude. Here's a code which produces a curve close to what is shown in Fig 3d. How to quantify it to six peaks, remains a question.
A = imread( 'Layer-5.png' ); % image from the article
A = double(rgb2gray( A ));
% gradient magnitude
dx = imfilter(A,fspecial('sobel') ); % x, 3x3 kernel
dy = imfilter(A,fspecial('sobel')'); % y
gradmag = sqrt( dx.^2 + dy.^2 );
% mask by disk
R = min( size(A)/2 ); % radius
disk = insertShape(zeros(size(A)),'FilledCircle', [size(A)/2,R] );
mask = double(rgb2gray(disk)~=0);
gradmag = mask.*gradmag;
% radon transform
theta = linspace(0,180,180);
vars = zeros(size(theta));
for u = 1:length(theta)
[rad,xp] =radon( gradmag, theta(u) );
indices = find( abs(xp)<R );
% ignore radii outside the maximum disk area
% so you don't sum up zeroes into variance
vars(u) = var( rad( indices ) );
end
vars = vars/norm(vars);
figure; plot( vars );
Bear in mind, images copied from the article appear with jpg artefacts. After good denoising (a tad too much here), e.g.,
you get much more prominent results.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With