Sequel of a Specified Region

sorry ImageAnalyst...
Unfortunately I deleted a question answered by ImageAnalyst and accepted by Me.
ImageAnalyst after doing filtering for particular portion is it possible to apply Fourier transform for that portion only to extract frequencies.

1 Comment

Par for the course. Not only do accepted (or unaccepted) questions I've answered get deleted, but it's been noted that sometimes people accept worse or wrong answers in preference to my better or "right" answers. I'm sure it happens to others also. You weren't the first and you won't be the last.

Sign in to comment.

 Accepted Answer

Image Analyst
Image Analyst on 28 Oct 2011
Yes, of course. You should know however that since your "infinite" image is multiplied by a mask (whatever region zeros out and crops stuff out) your spectrum will be convolved with the FT of the mask shape. Recall that multiplication in the spatial domain corresponds to convolution in the spectral domain.

6 Comments

Thankyou.. but when Iam using
FourierTransform=fft2(FinalImage);
Im getting the FourierTransform size same as FinalImage.I need only highpass filtered frequencies from the entire Image.
Did you crop out the mask region? It doesn't look like it. It looks like you took the FT of the whole image so of course the FT of the whole image looks like the FT of the whole image. At least that's what I assume you really want when you said "I need only highpass filtered frequencies from the entire Image." I assume you want the FT in mask region (like you said first) rather than the entire image which you said just now.
Now I cropped the Image(FinalImage) of polygon shape using
im_crop_size=size(finalImage);
vertex_x,vertex_y are the vectors of polygon coordinates
mask = poly2mask(vertex_x,vertex_y,im_crop_size(1,1),im_crop_size(1,2));
masked_im2 = bsxfun(@times,finalImage,cast(mask,class(finalImage)));
FT=fft2(masked_im2);
But to get only the highpass filtered freq values from the whole image(FT) I did like this
ReqFreq=FT.*binaryImage;
here binaryImage is my image containing 1's in the polygon region and 0's elsewhere.
can I do like this?
That should not work if your vertex_x and vertex_y coordinates are based on the full-sized image. They won't be in the right place for the cropped image and may even be out of bounds. And you can't draw a polygon over the spatial domain image and expect it to extract out spatial frequencies in the frequency domain. You can extract out frequencies in the frequency domain image (FT) if you multiply some mask by it, but you multiplied one I think you drew in the spatial domain, which makes absolutely no sense. Moreover, when you multiplied you're getting some really bizarre high frequencies because the highest frequencies are at the middle, which I doubt is what you expect because normally one uses fftshift() when one wants to do something like that. Then if you had used fftshift, you'd be getting the low frequencies not the high ones unless you inverted your mask to get the values OUTSIDE your mask not inside. So basically I don't even know what you're wanting to do but whatever you're doing seems totally misguided.
Thanks for the Information.....
But In your *Demo Of Filtering a particular portion of Image* I created the binary image by cropping the image in a polygon shape instead of selecting it with mouse as your code does because the polygon selected region contains EDGES so I thought to do highpass filtering for that portion and finally extracting frequencies of that region.
here vertex_x and vertex_y are coordinates of that polygon in binaryimage.
Please explain something about how to extract frequencies in the frequency domain image(FT) by multiplying by a mask.
Thanks In Advance
Yes, but the high pass filtered image was on the original image. I didn't crop it like you did. When you did that, your polygon now fell outside of your new cropped region, unless you take care to subtract an offset from your polygon coordinates. So do that subtraction and then your polygon will now lie over your cropped image, and you can do the masking. Then take the FT and you'll have it. I'd have all the images be single or double so you don't have any problems due to integer quantization.

Sign in to comment.

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!