How to remove the noise in this image??
5 views (last 30 days)
Show older comments
Hi, I am new to matlab and I have an assignment to segment the iris region of this image. Here is the code I have done so far.
clc;
clear all;
img = im2double(imread('1_L.jpg'));
subplot(3,3,1);imshow(img);title('Original image');
imgBW = edge(img, 'canny');
subplot(3,3,2);imshow(imgBW);title('Canny edge detection');
Thresh1 = 0.4;
Thresh2 = 0.7;
R1 = img < Thresh1;
R2 = img >= Thresh1 & img <= Thresh2;
R3 = img > Thresh2;
%//Zero-pad the regions so we can check the borders
R1 = padarray(R1, [1 1], 'replicate');
R2 = padarray(R2, [1 1], 'replicate');
%//Transform into columns
B1 = im2col(R1, [3 3]);
B2 = im2col(R2, [3 3]);
%//Extract size for later
[rows,cols] = size(R1);
%// Extract centre of each neighbourhood
middleB2 = B2(5,:);
% // Find the indices of those neighbourhoods that have 1 in the centre
windowsHaving1 = find(middleB2 == 1);
% // Access the corresponding neighbourhoods in R1
% // If ANY of them have a pixel of 1, then we know
% // these locations from R2 need to go back to R1
% // In that case, all you really have to do is take whichever
% // pixels are true, and set them to true in R1
% // See which neighbourhoods in `R1` have any pixels that are 1
% // given the corresponding region in R2
finalColumns = any(B1(:,windowsHaving1), 1);
% // Grab the indices of these columns
finalColumnsIndex = windowsHaving1(finalColumns);
% // Reasign those pixels that are neighbours to R1
B1(5, finalColumnsIndex) = 1;
B2(5, finalColumnsIndex) = 0;
%// Restructure back - Recall this image is padded
%// We took the rows and columns of the padded image
%// and so we need to subtract each dimension by 2
R1 = reshape(B1(5,:), rows-2, cols-2);
R2 = reshape(B2(5,:), rows-2, cols-2);
R3 = R2 | R3;
subplot(3,3,3);imshow(R2);title('Wanted region');
The problem is, I cannot fully turn the wanted region of the iris as the lower part has some darkness and I do not know how to remove the noise in the image. What am I doing wrong?? Is there a step I skipped??
3 Comments
Image Analyst
on 2 Apr 2015
And you forgot to attach your image (so we can't try your code) or show any intermediate images.
Answers (2)
shreevi vijayan
on 2 Apr 2015
yes u skipped a step called denoising.that is u have to remove noise in your image before using canny edge detector
0 Comments
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!