Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

image focus and FFT

I am a new to Matlab and I have a project that involves image processing.

I have a number of RGB images and I need to find a way to separate the out of focus from the in focus images. I do not need to correct the focus of the out of focus ones, I just need to find which are out of focus and remove them. I have done FFT2 to the image and then used the radial average of the image of the power spectrum to see if there is a difference between the in focus or out of focus but I do not see a difference between the two.

I decided to use the gradient of the image

[gradx,grady]=gradient(image) 

and then take the magnitude

new_image=sqrt((gradx.^2)+(grady.^2)) 

and try to do the FFT2 using the new_image now instead of the image. The power spectrum does not look like what I expect so I am not sure if I should do the FFT2 on the new_image of the gradx and grady separately. Has anyone have any thoughts about whether this is the right way to do this?

I was also thinking that instead of using the gradient to use a Sobel mask

mask=fspecial('sobel')
mask_x=imfilter(image,mask)
mask_y=imfilter(image,mask')
new_image=sqrt((mask_x.^2)+(mask_y.^2))

and then do FFT2 in the new_image but again the power spectrum is not right. I expect it to start from zero and instead it starts from the highest value and drops exponentially.

Has anyone tried to classify images using this method? Thank you for reading.

like image 836
user3043257 Avatar asked Feb 06 '26 13:02

user3043257


1 Answers

A DCT, instead of an FFT/DFT, will get rid of any high frequency discontinuities between the opposite edges of your images.

like image 158
hotpaw2 Avatar answered Feb 09 '26 12:02

hotpaw2



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!