MATLAB Working with Edge function in MATLAB

Click For Summary
The discussion focuses on using the edge function in MATLAB to extract pixel coordinates from a specific curve within a defined region of an image. The user seeks a method to identify the index of the bottommost "1" in each row of a binary matrix derived from the image. Suggestions include creating a search algorithm that iterates through the specified area to find these coordinates while addressing potential issues like image artifacts and discontinuities in the curve. The conversation emphasizes the importance of defining the search orientation and handling complexities in the edge structure. Overall, the guidance provided aims to streamline the extraction process and improve accuracy in identifying pixel locations.
member 428835
Hi PF!

Attached is an image I generated using the edge function in MATLAB (except the arrows, obviously). I would like to extract just the coordinates of the pixels from the bottom curve, which I've pointed at with arrows, and only in the domain between the red lines.

Does anyone know how to do this?

Thanks so much!
 

Attachments

Physics news on Phys.org
Thanks, that was great as far as identifying the region I'm interested in! Now instead of a binary matrix spanning the entire image I have a new matrix of smaller dimensions, given by the red box in the attached image. Since this image has only 1's and 0's, and since I want the bottom line in the box that the arrows point to, I was thinking all I really need is the index (row and column position) of the "bottom" 1 (since 1's denote a white pixel) in for each row. Do you know of a simple way to ask MATLAB for this info?
 
joshmccraney said:
that was great as far as identifying the region I'm interested in
I believe it does more than "identifying the region"-- as you hover over the line of interest you get x,y information for each pixel of interest. Manually, you could have your result in maybe 30 min.

It was not clear in your OP that automation was your intent or generalization for that matter. But not a problem. A couple issues, though.

Clutter removal. The red box you identify has distracting information (part of your "close valve 2 knob", etc.) You could make a smaller box to get past that, but for future images, you must deal with the possibility of image artifacts appearing randomly in your box.

Discontinuities in your "line of interest". I count what looks like at least 3 discontinuities. What constitutes an image-artifact discontinuity vs an actual real "notch" occurring in something that is presumably smooth, is up to you to define and manage.

Concave/Convex (complex line). How nonlinear of an edge to you need to handle?

Search Orientation. You can create something in MATLAB to handle this "horizontal", "bottom-first-encounter" case fairly simply (advised below), but to make it work in a more general manner (horizontal top-first, or vertical left/right first case) is going to require more consideration.

Advice:
This specific problem (hoizontal, bottom-first, no concavities, potential discontinuities, no clutter) lends itself to a search beginning at, say, the leftmost column (c0) and bottommost row (r0) of the rectangle. You can come up with a simple inner-outer loop structure: advancing over all columns (c0 to cn) in the outer loop, and for each column, increment the row elements (from r0 to rn) testing for the first occurrence of a "1" in the inner loop. Store your detection points in a suitable array.

As far as the discontinuities are concerned, you can post-process your result to smooth the result based on a smoothing algorithm of your design. The point being: isolate this process from the search process.
 
Thanks a lot! I really appreciate your help! Makes my life a lot easier!
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 3 ·
Replies
3
Views
1K
  • · Replies 15 ·
Replies
15
Views
2K
  • · Replies 7 ·
Replies
7
Views
8K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 3 ·
Replies
3
Views
7K