# Plot angle vs intensity histogram from image center

Basically I'm selecting a circular area in the image(gray scale DFT image) where image center coordinates are the center of the circle.I want to plot angle vs intensity variation for the area covered by this circle.My idea is to use a virtual line through image center with the length of circle diameter and move by 1 degree and sum up total pixel intensity values covered by that line.Similar approach is mentioned in below links,

finding-intensity-along-a-moving-line-in-an-image-and-compiling-to-give-an-angle-vs-intensity-plot

how-to-plot-intensity-images-i-e-any-angle-between-0-and-360-degree

I would like to know is it possible to achieve such a thing using OpenCV + python (It seems not that easy)? Or is there any other approach for plotting angle vs intensity histogram through image center?

I was initially thinking to get logPolar transform of the image and access angle and intensity values from it.But i was not sure whether it was a possible approach since i couldn't even interpret logPolar transform output in an informative manner.(It just returns logploar transformed image, not angle and log magnitude vectors from the image center)

Any suggestions would be appreciated...

edit retag close merge delete

Sort by ยป oldest newest most voted

opencv is a computer-vision library, and not really suitable for plotting.

also, logPolar / warpPolar seem to be the opposite of what you wanted.

there's phase(), magnitude(), polarToCart() to retrieve useful information, but in the end, this is not the appropriate library for your job (imho).

more

1

Thanks for the reply.Really appreciate it.But i like to clarify somethings in here.

I'm not really worrying about the plotting.It can be done using some other library.My concern is that, is it possible in OpenCV to access intensity values all the pixels of an image that make same angle (clockwise or counterclockwise) with the image center?

Seems in-built functions you have mentioned in here are not useful in my scenario since, 1. Angle is measured in these functions respected to the origin instead of center 2. I can't directly apply polar coordinates since my requirement is not depending on both angle and magnitude values.Instead it is only based on angle.

( 2018-11-08 01:48:20 -0500 )edit

yea ;( it also seems, you're not even using opencv's dft (which is not "centered" by default)

the c++ api has a LineIterator class, which would allow you to traverse the radius for a given angle, and sample the underlying Mat (that's more or less, what your links there proposed, no ?, but not available in python.

( 2018-11-08 02:04:02 -0500 )edit
1

For radial distribution I use this https://github.com/LaurentBerger/wxOp...

( 2018-11-08 03:04:11 -0500 )edit

Thanks for the suggestions.I think it is better to explain the approach i took for any future reference.

1. I've used OpenCV with Numpy
2. Apply a circular convolution for my DFT image after low frequency components are moved to the image center
3. A dictionary is defined with key : angle and values : intensity values of pixels with same angle
4. While iterating through each row(i) and column(j) , calculated pixel(i,j) angle with respect to the image center (I,J) using np.arctan2(I - i , J - j) and updated the dictionary

Note : Even though this method is working, you'll notice that angles such as 0, 45, 90, 180 has way more pixel points than others.This is due to square shape of pixels.

more

Official site

GitHub

Wiki

Documentation