In-variance to Gaussian Noise and Scaling for given Finger Detection Algorithm

1 view (last 30 days)
Hi,
I have written a programs that uses Matlab IPA toolbox in conjuction with a custom image processing toolbox named VSG to detect fingers (from a set of four hands in a single colour image) and display the number of fingers for each hand using a highlighting technique (Centroid). Once the fingers are displayed the program needs to be tested for Gaussian Noise and Scaling. Also the program should only use Data Driven thresholding and not fixed thresholding.
Here is the image that I am perusing - http://s28.postimg.org/g66q2pk7h/hands_all.jpg
%%Prepare the Image for Analysis
% load binary image and convert to greyscale
A_hands=imread('hands_all.jpg');
A=rgb2gray(A_hands);
% add user defined Gaussian Noise to the image with mean and variance parameters
A_noise=vsg('GaussianNoise',A,0);
A_noise=uint8(A_noise);
figure, imshow(A_noise), title('Gaussian Noise Image');
% scale the image
dimx=0;
dimy=0;
A_scale=vsg('ScaleImg',A_noise,dimx,dimy);
A_scale=uint8(A_scale);
figure, imshow(A_scale), title('Scaled Image');
% display results
%h=figure;
%subplot(2,2,1); imshow(A_hands), title('Original Image'),
%subplot(2,2,2); imshow(A), title('Greyscale Image');
%subplot(2,2,3); imshow(A_noise), title('Gaussian Noise Image');
%subplot(2,2,4); imshow(A_scale), title('Scaled Image');
%set(h,'Name','Input Images')
%%Start Analysis on the Image
% data driven thresholding
hi_g=vsg('HighestGrey',A_scale);
low_g=vsg('LowestGrey',A_scale);
tuning_factor=0.723;
hist_thresh=uint8((hi_g+low_g)*tuning_factor);
A_thresh=vsg('Threshold',A_scale,hist_thresh);
A_thresh=uint8(A_thresh);
A_inv_thresh=vsg('NOT',A_thresh);
A_inv_thresh=uint8(A_inv_thresh);
figure, imshow(A_inv_thresh), title('Data Driven Threshold Image');
string1=['Data driven threshold = ' num2str(hist_thresh)];
disp(string1);
% clean display image using morphological operation
A_cleaned=imopen(A_inv_thresh,strel('arbitrary',[0 1 0; 1 0 1; 0 1 0]));
A_cleaned=uint8(A_cleaned);
figure, imshow(A_cleaned), title('Morphologically Cleaned Image');
% fill the holes in the image to get a smooth looking thresholded binary image of the hands
A_filled=vsg('BlobFill',A_cleaned);
A_filled=uint8(A_filled);
figure, imshow(A_filled), title('Smooth Threshold Binary Image');
%%Count Hands and Fingers and Display Count Number in Command Window
% find centroid of each hand and count the number of hands
H=vsg('Centroid',A_filled);
H=uint8(H);
H_count=vsg('WPCounter',H);
h=figure; imshow(H); title('Centroid Labeled Image of Hands')
point_label(H,A_hands,30); % calls a function named point_label from the same directory
set(h,'Name','Fingers Labeled with Centroid Points');
string1=['There are ' num2str(H_count) ' hands in this image'];
disp(string1);
hands=A_filled;
for i=1:H_count,
isolated_hand=vsg('BiggestBlob',hands);
hands=vsg('XOR',hands,isolated_hand);
%h=figure; imshow(uint8(isolated_hand)); set(h,'Name','Isolated Hand for Analysis');
%get the width of hand and all finges
[maxDistanceImage] = maxDistance(isolated_hand);
%get median width
medianHandWidth = median(nonzeros(maxDistanceImage));
%discard all the rows having width more than 1/2 of hand width
fingerImage = (maxDistanceImage~=0) & (maxDistanceImage < medianHandWidth/2);
h=figure; imshow(fingerImage); set(h,'Name','Finger Image');
%clean image using morphological operation
fingerImage = imerode(fingerImage, strel('square', 5));
% find centroid of image
F=vsg('Centroid',fingerImage);
F=uint8(F);
finger_count=vsg('WPCounter',F);
h=figure; imshow(F),title('Centroid Labeled Image - Fingers');
point_label(F,A_hands,30); % calls a function named point_label from the same directory
set(h,'Name','Fingers Labeled with Centroid Points');
% print the number of fingers in the command window
string2=['There are ' num2str(H_count) ' hands in this image'];
disp(string2);
string3=['There are ' num2str(finger_count) ' fingers in this image'];
disp(string3);
title(['There are ' num2str(finger_count) ' fingers in the selected hand']);
xlabel(['There are ' num2str(H_count) ' hands in this image']);
end;
for the above program the call function point_label is given below which adds a highlight colour for the centroids computed -
function output_img = point_label( point_img, source_img, marker_size );
% Highlight detected hits on the original image
% uses edge detector to store points
figure('Name','detected points overlay','NumberTitle','off'),
C = corner(point_img);
imshow(source_img);
hold on
plot(C(:,1), C(:,2), 'b.', 'MarkerSize',marker_size);
end
The program calculates all the fingers and highlights them using Centroid function. Program is also invariant to Gaussian noise for zero mean (mean should not be changed) and up to a value of 3.5 for variance. But when I add a value for scaling the program still calculates the right number of fingers and hands but plots the Centroid highlight all over the image rather than the centre of each finger. How can I fix this? Also I am sure this isn't the best way to implement the program. I would welcome any suggestions to improve this program and make it invariant to at least some amount of Gaussian noise and Scaling factor.
Any help is appreciated. It's been 8 or so weeks since I have just begun to learn how to use Image Processing and it is part of my curriculum.
Regards Ashton

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!