Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Image Processing - Using Radon Transform for Pattern Recognition in MATLAB

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.

Results Image (Left : Article's Results, Right: My Matlab results Input Image

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

like image 440
User404 Avatar asked Dec 22 '15 18:12

User404


1 Answers

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.,

denoised image

you get much more prominent results.

like image 124
mainactual Avatar answered Sep 19 '22 18:09

mainactual