cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

Extract multiple subregions from single image?

ScottMilligan
3-Visitor

Extract multiple subregions from single image?

I am wondering whether it is possible using the selection rectangle in the picture toolbar to extend the built in subregion selection capability to select more than a single subregion in a displayed image, and then output both the coordinates and contents (values)of the selection rectangles to a vector of specified variable names.

I suppose I could simply copy and paste each selection manually, but was hoping someone might have a more elegant idea using either a scripted component, an MDA definition, or some other approach I haven't yet imagined. I haven't yet put a lot of thought into this and so am not "wedded" to any particular approach.

My application envisions looking at an image consisting of multiple images of several illuminated pinholes, subsequently extracting peaks and centroids using the localmax function and several useful ideas developed in this collab by Tom G, JMG, Philip O, and others in response to a project initiated in April 2008 by J Bryant.

Any thoughts on how to best organize the subregion extractions would be received with interest and gratitude.

Scott Milligan
5 REPLIES 5

The original extractor for Jason project is manual by dragging a square/rectangle and automatic capture instead of dragging and manually copy/paste. I don't recall if the "Jason way" displays the coordinates as you drag ? But dragging over in the picture tool, it gives the coordinates of the regions. You seem to be talking about extracting several regions at once from the big image. Up to the mind, there appears dirty ways of doing. But often, from an initial thinking, the issue is a great tool. If all regions would be equal, that would be easier ! ?

It is easy to place/replace one region at a time via program. Can the process be extended to several regions ? manually yes, automatically ??? Can we collect: YES, redisplay any selection: YES, can we save in file: YES.

jmG

Not sure what you mean by multiple images. Do you mean a collage of several images, each with several pinholes? Or a single image of multiple pinholes?

Do you really need manual selection? What are you trying to select? If you're just trying to find the pinholes in the images, you can probably use an automated peak finder for the purpose. Do a bit of smoothing to remove high frequency noise and search for peaks in the resulting image. SHould work if the pinholes are reasonably well separated.

I don't think there's any way to get multiple selections out of a single image viewer. But you can have a scripted component that accumulates values from individual selections. Perhaps a pushbutton. When you push the button it adds the current output to the accumulated values. A double click to clear the accumulation and start fresh. It could be arranged to have the accumulated values preserved with the worksheet when saved. Might even be possible to mark the selected areas.
__________________
� � � � Tom Gutman

Just attach an image and describe what the project consists of. My understanding is that you want to specify several regions (maybe of different size), then collect those regions then analyse each region particularly and specifically.
Is there a way of automating the picture tool to display each region as they would be selected by the submatrices definition as they come defined and display the coordinates ???
From the Jason original way, you could write to file each selected region and maybe re-collect in a nested array. Like Robert said: there are many ways to skin a cat !

jmG

Thanks to all who have replied. To clarify my intent, I wish to examine a single image frame that contains multiple instances of pinhole images. Typically these are equi-spaced in either the column or row directions, but not in the orthogonal direction (i.e. equi-spaced along rows, but not in columns).


I have successfully adapted the work done with Jason's project to extract the peaks using localmax function, and from there I can find the centroids, fit 3D Gaussians, extract cross-sections, etc, yielding a very nice tool for pinhole image analysis; many thanks to all who worked with Jason to demonstrate the different ways to skin the cat in MathCad.


The motivation behind my original question stems from the fact that there are often many pinhole images in the frame that I would like to ignore, selecting only a subset to use in calculations that basically measure geometric distortion in a rectangular grid of the most widely separated pinhole images on the frame. The selected subset regions can all be the same size, although this is not required, since I am only interested ultimately in extracting the coordiantes of the image centroids. I do, however, need to preserve the global X Y coordinates that locate each centroid on the overall image frame.

My first thought was that giving the sheet user a drag-select interface would provide a convenient means for specifying which pinhole images to consider.



However, realizing that all of the centroids will have been previously extracted, I would also consider a user input that tells MathCad how many subregions to include in the selected subset within a given radius from the center of the frame, and then, for example, impose additional contraints that require maximizing and equalizing distances between certain image pairs such that the resulting subset of chosen pinhole images forms a rectangular grid of maximal area within the overall image frame. Looked at this way, the centroid data has already been determined, and I would a filter function program to reject data points that don't satisfy the user input selection criteria.




I was just fishing for ideas as to how some of you reading this might attack the same project.




Scott Milligan

Scott,

Converting your proposal in "printable language", i.e: something that prints in the mind, it resumes to "matrix calibration" of some kind. Matrix calibration meaning adjust the entire matrix of the CCD capture so that all the sampled regions will respond equally to the center pinhole, i.e: the pinhole at the center of the entire image. Thus, like you explain, you need the collection of the pinholes, collected like grid. In fact, this is the most used way the image smoothing is performed, by convolving the image over a cross shaped kernel for smoothing in both directions.

Once you would have collected the "pinhole grid regions" and established the matrix of the scaling factors, it would be apparently possible to "fit the pinhole" calibration matrix scalar, then in the reading process of the real image, vectorize the captured by the calibration.

That's my understanding, please correct as required.

So, given the " pinhole grid result" the problem is to fit a more general interpolating Gaussian of same size as the pixel size of the entire image. That step looks easy. The automatic collection of all the pinholes seems possible ... then address and collect all pinhole regions, average each region as the data reference for fitting the scalar by which to vectorize the captured CCD.

jmG
Top Tags