ImageJ application for scientific computing

I have a problem in which I want to map the complex plane with black and white square pixels, and then find the largest continuous group of white pixels within a radius of the origin. I know the software which identifies such things is tediously complex, and the best way of doing it is much, much better than the naive while loop I myself would code. Therefore, I have chosen the open source package Image J.

Image J helps “you develop and share reproducible analysis workflows.” I think the problem I want is not so specific that there does not exist a standard module which does exactly what I want. I want to scan an array of black and white pixels, and then sort the groups of white pixels based on size within a certain radius of the origin. Does there exists some purpose built module, more specific than Image J? Image J deals with images, but since my problem is only black and white pixels in 2D, perhaps a module that takes an input file as some non-image .dat file? Perhaps a binary file giving 1/0 for black/white?

I want to ask something like, ``What is the largest square of only white pixels within 100 pixels of the origin ?" (scale up later) Then I will ask, “What is the distribution of the sizes of the squares of decreasing side within a given radius?” My concern is that by formulating the problem in terms of an image file, I have made things much too complicated. Is an image processor like Image J an unneeded layer of complexity? If so, what module lets you tile the plane with square pixels and then examine the distribution for the different tiling functions? I can make an input as an image file, or as binary file where the 1s and 0s are the black an white pixels.

Thank you for your careful consideration that my primary goal is to study the behavior of the tiling functions by which I map the complex plane with black and white pixels, and when I have described the initial condition .dat file for my counting algorithm, I was wondering if image processing software might be the most efficient. On second thought, counting black and white pixels might be something so common that hyper-efficient dedicated modules exist outside of image processing.

2 Likes

Hey @sevensixtwo,

that sounds like a very interesting project! I don’t really get the complex plane thingy, but statistics on sizes and shapes of white objects is something people do in ImageJ every day… I’m just wondering: you’re searching for squares… Have you heard of the Hough transform? It should allow you to detect any kind of shape of any sizes… Just thinking loudly :wink:

I’m pretty sure you can do that with ImageJ, but you might consider alternatives such as Matlab and Python which are a bit closer to math, which might be beneficial in your project…

Btw. can you share an example image? For curiousity and also to allow us guiding you to suitable plugins :wink:

Cheers,
Robert

Here is the problem I have in mind. The tiling function colors a square (x,y) black if it is a Gaussian prime number, and it is white otherwise. This tells you about complex numbers z=x+iy when x,y are integers. The image shows all of the plane, but I might split it up into quadrants. Do you see what I’m saying though about possibly over-complicating it by using an image at all?

1 Like

Wow, beautiful!

So I’d say an image is good for visualization but the problem you want to solve might be better treated with loops and functions. The result (pixel/square? density?) might again be better visualised as image… How about using python, numpy and scikit-image?

1 Like

This can be done using morphological operations. If squares is what you’re looking for, you can to this by morphological opening/closing:

If you’re looking for continuous (convex) groups of pixels (not necessarily squares), also the built-in Watershed might do it. Here’s just a quick, imperfect trial:

image

2 Likes

Yes, I am familiar with numpy and I like it. Rather than writing my own loop to do it, I want to find an optimized module. I have chosen Image J to install, but I could easily install python and run a python module. The point is that rather than taking the time to write my own code, I want to take the time to find the best code. Maybe I am too optimistic about totally avoiding coding for such a specific problem, but this problem, “How big is the biggest white space of a certain shape?,” is something I think must be very standard.

I am unclear about what you consider to be “a group” of pixels?
What connectivity are you allowing? 4- or 8-neighbours or something else?
What if your “group” intersects the boundary of the disk, do you consider the disk boundary to be a group boundary as well?
All these issues will have a consequence on what you measure.