Working with Edge function in MATLAB

In summary, the conversation discusses using the edge function in MATLAB to generate an image and extracting coordinates from a specific region within the image. The solution suggested is using the impixelinfo function and manually identifying the desired pixels. However, the person asking the question is looking for a more automated approach and seeks advice on how to do so. The conversation also touches on potential challenges such as image artifacts and discontinuities. The summary concludes with advice on using a search process to detect the desired pixels and addressing potential issues through post-processing.
  • #1
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

  • edge.pdf
    65.7 KB · Views: 278
Physics news on Phys.org
  • #3
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?
 
  • #4
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.
 
  • #5
Thanks a lot! I really appreciate your help! Makes my life a lot easier!
 

1. What is an edge function in MATLAB?

An edge function in MATLAB is a built-in function that allows you to detect and highlight the edges or boundaries of objects in an image. It uses various algorithms to identify changes or discontinuities in pixel values and marks them as edges.

2. How do I use the edge function in MATLAB?

To use the edge function in MATLAB, you need to have an image loaded into your workspace. You can then use the command "edge(image, method)" to detect edges using a specific method. The output will be a binary image with 1s representing edges and 0s representing non-edges.

3. What are the different methods available for edge detection in MATLAB?

There are several methods available for edge detection in MATLAB, including Sobel, Prewitt, Roberts, Canny, and Laplacian of Gaussian. Each method has its own advantages and is suitable for different types of images. It is recommended to try out different methods and choose the one that gives the best results for your specific image.

4. Can I customize the edge detection parameters in MATLAB?

Yes, you can customize the edge detection parameters in MATLAB to suit your needs. The edge function allows you to specify parameters such as the threshold, sigma value, and filter size for certain methods. You can also adjust these parameters to see how they affect the detected edges.

5. Is edge detection in MATLAB accurate?

The accuracy of edge detection in MATLAB depends on various factors such as the quality of the image, the chosen method, and the parameters used. In general, MATLAB's edge function is a reliable and efficient tool for detecting edges in images, but it is always recommended to visually inspect the results and make adjustments if necessary.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
751
  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
15
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
901
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
Back
Top