original image:
characterized:
In the above image, each circle has a position (denoted by the blue x) and radius (denoted by the blue circle) that is identified by the routine. The red x's are the "ideal" location of the centers, basically with the jitter removed. We are interested in knowing the variation (sigmas) of each feature, so I needed to do a bit of processing to identify the actual centers and the ideal centers.
I use the FFT and correlation with a known circular kernel to identify the size and position of each feature. Right now I have to do it rather inefficiently. I write my own program to call imagemagick with the appropriate parameters. IM does the FFT, processing in the frequency domain and IFT back into the time domain. I then save it as a pgm which I can read by my program to do the final post-processing to extract the information such as the island centers etc. The program is currently written in C.
The program also produces a txt file which looks like this:
Code: Select all
# x y x_ideal y_ideal dist r metric value
0 252 17 254 11 6.32 15 3278 7609
1 321 17 318 12 5.83 14 3660 7459
2 384 17 382 12 5.39 15 2822 7457
3 761 16 762 19 3.16 14 2823 7679
4 821 16 825 20 5.66 14 3976 8245
5 445 15 446 13 2.24 14 2849 7857
6 574 15 574 16 1.00 14 2610 7702
7 697 17 700 18 3.16 15 2189 7733
8 1013 20 1012 21 1.41 16 3396 7541
I am interested in learning how to modify IM to somehow merge my routine to be called from within IM. Right now my program is called as follows:
characterize -N 1200 -M 830 -r 10 -R 22 -B 2 016216.jpg
This assumes an image of size 1200x830, and does a radius search from 10 pixels to 22 pixels and includes a blur of radius 2 in the kernel. It then convolves 016216.jpg with circular kernels within the given radii in the given range and finds the peaks which denote the locations of maximum correlation. I also have an algorithm to determine the best fit radius.
I would like to work on integrating these features back into IM, I envisage it being called, perhaps something like this:
convert 016216.jpg -geometry 1200x830+10+22 -blur 2 -characterizeCircles
Could someone give me a leg-up into how to edit the code for IM to integrate my external program in? If there is interest, to have such capability in IM, I would be happy to contribute the code back.