Working with Edge function in MATLAB

  • Context: MATLAB 
  • Thread starter Thread starter member 428835
  • Start date Start date
  • Tags Tags
    Edge Function Matlab
Click For Summary

Discussion Overview

The discussion revolves around using the edge function in MATLAB to extract pixel coordinates from a specific region of an image. Participants explore methods for identifying and processing pixel data, particularly focusing on the bottom curve of a binary matrix derived from the image.

Discussion Character

  • Technical explanation
  • Conceptual clarification
  • Homework-related

Main Points Raised

  • One participant seeks to extract pixel coordinates from a specified region in an image using MATLAB's edge function.
  • Another participant suggests using MATLAB's impixelinfo function to help identify the region of interest.
  • A participant notes the need to find the index of the "bottom" 1 in each row of a binary matrix, indicating a desire for automation in this process.
  • Concerns are raised about image artifacts and discontinuities in the line of interest, suggesting that these factors must be defined and managed by the user.
  • Discussion includes considerations for handling complex edges and search orientations in the image processing task.
  • A proposed approach involves creating a loop structure in MATLAB to systematically search for the first occurrence of a "1" in the specified region.
  • Post-processing techniques are mentioned to smooth results and address discontinuities after the initial search.

Areas of Agreement / Disagreement

Participants express varying degrees of agreement on the methods to approach the problem, but no consensus is reached on the best practices for handling discontinuities or image artifacts.

Contextual Notes

Limitations include the need for clarity on the automation intent, the handling of image artifacts, and the complexity of the edge being processed. The discussion does not resolve how to manage these factors effectively.

Who May Find This Useful

Individuals working with image processing in MATLAB, particularly those interested in edge detection and pixel data extraction techniques.

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
3K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 3 ·
Replies
3
Views
1K
  • · Replies 15 ·
Replies
15
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 7 ·
Replies
7
Views
8K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 6 ·
Replies
6
Views
2K