Smoothing outer circular portion of image

Hello guys,
I am working on iris detection in which I am interested in obtaining only the of the central circular portion of the image and blur the image from boundary to certain point circularly. Could you please help me in getting the rest of the code correct. I guess there's something wrong in x from the beginning.
x = 10; filter = ones(x,x); filter = sin(????); image=fft2(image.*filter)

Answers (1)

Lots wrong with this. First off, don't use image as the name of a variable since it's a built-in function.
Secondly you need to create a circular mask - see the FAQ: http://matlab.wikia.com/wiki/FAQ#How_do_I_create_a_circle.3F. You may want to create two and subtract them to create a ring if you just want to blue the boundary between the iris and the white.
Next, you don't need to do anything with Fourier. Simply do it in the spatial domain:
windowWidth = 15;
kernel = windowWidth(windowWidth , windowWidth) / windowWidth ^ 2;
blurredImage = imfilter(grayImage, kernel);
% Then assign blurred pixels to your binary mask.
outputImage = grayImage; % Initialize
outputImage(binaryImage) = blurredImage(binaryImage);

5 Comments

M = imread('fly;, []); M = rescale(crop(M,242));clf; imageplot(M, 'Original', 1,2,1);
% Create a logical image of a circle with specified diameter, center, and image size. First create the image. imageSizeX = 640; imageSizeY = 480; [columnsInImage rowsInImage] = meshgrid(1:imageSizeX, 1:imageSizeY);
% Next create the circle in the image. centerX = 320; centerY = 240; radius = 100; circlePixels = (rowsInImage - centerY).^2 + (columnsInImage - centerX).^2 <= radius.^2; % circlePixels is a 2D "logical" array. % Now, display it. image(circlePixels) ; colormap([0 0 0; 1 1 1]); title('Binary image of a circle');
windowWidth = 2; kernel = windowWidth(windowWidth , windowWidth) / windowWidth ^ 2; blurredImage = imfilter(M, kernel);
outputImage = grayImage; % Initialize outputImage(binaryImage) = blurredImage(binaryImage);
This is giving the fllowing notification: Index exceeds matrix dimensions.
Also wouldn't it be simpler to implement the blurring of boundary using sine window function followed by convolution.
Well you didn't adapt the code at all. You can't just copy the faq code into your program and expect it to work. For example, it's using an image of size 480 x 640. Is yours that size? Probably not, so you need to adapt it.
Pardon my ignorance but I'm basically trying to run this code and wanted information for the one below. How could I modify Fs and t so as to adapt to the image itself? Please help! This is the last part and I have kind of no knowledge related to it
M = load_image(name, []); M = rescale(crop(M,n));clf; imageplot(M);
Fs = 1500; t = (0:100-1)'/Fs;
sinwave = sin(2*pi*15*t); w = window(@flattopwin, 100); sinwin = sinwave .* w; plot(sinwin)
This sounds like a totally different question. One I can't answer because I don't know what those functions are: load_image(), rescale(), window(), flattopwin().
It's not hard to do what you asked first. Just define a binary image somehow - either find the iris somehow, such as imfindcircle() or color segmentation or draw it manually with imellipse - then create a mask to define the parts you want blurred or not, then use the code I gave you.
Why don't you upload an image where you've indicated, with colored lines, what part of the image you want blurred?

Sign in to comment.

Categories

Tags

Asked:

on 13 Jan 2014

Commented:

on 14 Jan 2014

Community Treasure Hunt

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

Start Hunting!