Ask Your Question

fery's profile - activity

2020-09-28 23:38:26 -0600 received badge  Popular Question (source)
2020-09-28 23:35:32 -0600 received badge  Popular Question (source)
2015-05-29 07:21:45 -0600 received badge  Self-Learner (source)
2015-05-29 07:21:13 -0600 answered a question spatial frequency corresponding to the image plane

I found the answer on my own, just for those who maybe have the same problem:

x=im.shape[0]
y=im.shape[1]
fft =  np.fft.fft2(im)
fshift = np.fft.fftshift(fft)
#the frequencies will be shifted to the center:
fshx=np.fft.fftshift(np.fft.fftfreq((fft.shape[0])))
fshy=np.fft.fftshift(np.fft.fftfreq((fft.shape[1])))
for i in xrange(x):
     for j in xrange(y):
         fre = np.sqrt(fshx[i]**2 + fshy[j]**2)

it works for me as I expected, hope its correct :P

2015-05-26 03:05:06 -0600 asked a question spatial frequency corresponding to the image plane

Hi everybody

I am doing image filtering in frequency domain, and I need to find the frequency of each image pixel . the only thing I know about the image is size of image for example: (225, 225)

There is a function in python "np.fft.fftfreq" to calculate frequencies, but two question arises here:

  1. Using this function, I have to find the frequency in x and y direction , so two numbers, but i need one number for each pixel (I need a matrix the same size as image fill with frequencies correspond to the image pixels)?

  2. it starts with zero!!! but as I know after shifting fft, DC component is in the middle so why zero at the beginning?

if anybody knows another way to calculate the frequencies, more than welcome :)

2015-05-21 08:29:07 -0600 commented question Image filtering in frequency domain python

you mean that the filter is not for blurring?????? it should blur the image, but just make it a little darker!!!

2015-05-21 07:23:46 -0600 commented question Image filtering in frequency domain python

Ah got it, its symmetric. but its not working like this i won't get a blur image it just make the image a little darker just it!!!!

2015-05-21 05:53:34 -0600 commented question Image filtering in frequency domain python

LBerger, thx for your answer. u are telling that i don't need to shift the image to have DC in the center. and just divide the pixel number to the number of rows and col ? what do u mean by hermtian symetry? how it affects?

2015-05-21 03:07:40 -0600 received badge  Editor (source)
2015-05-21 03:06:16 -0600 asked a question Image filtering in frequency domain python

Hi everybody,

I am new in programming and I would like to apply a filter on an image in frequency domain. actually, its from a paper and i want to re implement it. its the formula: im_out= (1+ 5*((1-e^-f)/f)) * im_in and here are my codes:

im = cv2.imread('lena.jpg',0)

x=im.shape[0]

y=im.shape[1]

fft= np.fft.fft2(im)

fshift= np.fft.fftshift(fft)

freqx = np.fft.fftfreq(fft.shape[0])

freqy = np.fft.fftfreq(fft.shape[1])

zr = freqx==0

freqx[zr]=0.000000001

for i in xrange(x):

  for j in xrange(y):

    filter = 1+(5*(1-np.e**(-1*(np.sqrt((freqx)**2 + (freqy)**2))))/(np.sqrt((freqx)**2 + (freqy)**2)))

fim= fshift* filter

fishift= np.fft.ifftshift(fim)

imback=np.fft.ifft2(fishift)

imback=np.uint8(np.real(imback))

plt.subplot(221)

plt.imshow(im,cmap='gray')

plt.subplot(222)

plt.imshow(imback,cmap='gray')

plt.show()

but i get the image without any visible changes, it should be kind of low pass filter. now I am wondering if its correct to use np.fft.fftfreq to find "spatial frequency in the image plane". or I should use distance from center as "f"?!!! in the paper they said "f" is spatial frequency of the image plane!!!!

could anybody help me plz !!!

2015-02-19 04:36:00 -0600 commented question what is the fastest way to do patch-based image analysis

StevenPuttemans: I would need later to go for neighborhood, so don't think parallel can help me :(

2015-02-19 04:19:34 -0600 commented question what is the fastest way to do patch-based image analysis

yep, at this moment

2015-02-19 04:12:11 -0600 commented question what is the fastest way to do patch-based image analysis

about 20 sec FooBar

2015-02-19 04:11:21 -0600 commented question what is the fastest way to do patch-based image analysis

ah I am looking for high luminance occurrence in every patch:

img= cv2.imread("3.png")
window= 5
overlap= 4
h, w= img.shape

    gridx = xrange(0, w - window, window - overlap)
    gridx = np.hstack((gridx, w - window))

    gridy = xrange(0, h - window, window - overlap)
    gridy = np.hstack((gridy, h - window))

    for i in xrange(len(gridx)):
        for j in xrange(len(gridy)):
            xx = gridx[i]
            yy = gridy[j]
            patch = img[yy: yy + window, xx: xx + window]
            mean = np.mean(patch)
            if (central_v-mean) >(np.std(patch)/2):
                        print "HL"
2015-02-19 03:46:02 -0600 commented question what is the fastest way to do patch-based image analysis

What do you mean Berak? its way faster using c++ opencv, ok I know c++ is faster than python but the difference is more than i expected. and also I am doing very simple calculation on every patch why should it take that long?

2015-02-19 03:37:10 -0600 asked a question what is the fastest way to do patch-based image analysis

hi,

I am trying to do some analysis over an image but i need to do that patch by patch. I am using opencv python for this purpose. but this way it takes long time(3 mins) for an mid resolution image (1980 * 1020),

is there any fast way or its the best that i can get?!

2015-02-18 09:45:41 -0600 asked a question can not read a video using opencv!

hello every body I am using python in Ubuntu, i tried to read a video using opencv but can't cuz the while statement for cap.isOpened() is never true!! then can't see the frames! I've read videos before using python in windows and never had a problem, is there anybody who can help me find out the problem?!