0

I'll start off by saying I'm new to MATLAB, and this is the first time I'm trying an application related to image processing.

I'm building a MATLAB library (which is to be used in a Windows Phone Application), which takes in an edge map of a natural image as input. I need to traverse the map row-wise. If I come across an edge, I need to find the local minimum and local maximum of the edge.

I need help figuring out how to; 1) traverse the edge map - row-wise 2) detect an edge 3) find the local minimum and local maximum of the edge

Appreciate any help. Thanks in advance :)

  • Would be nice if you had a bit of code or speudocode, even a bit further information about your data would be nice. I guess you use a colour image? or is it grayscale?. And my biggest problem right now is that i don't really understand your points 1) and 2). Do the pixel values of the image represent phase values or sth. like that going in values of mod(2pi) and then jumping back to 0 or what do you mean with edge?. Your 3) point is quite easy. The methods `min` and `max`used on a matrix return a row vector representing the minimums and maximums of each column. – The Minion May 15 '14 at 06:43
  • SInce you want it row-wise you can just transpose your matrix and use those commands then. Transpose is done by `'`. So your command for row-wise minima would be `min(Matrix')` – The Minion May 15 '14 at 06:44
  • For your problem with edge detection i found this link: [mathworks](http://www.mathworks.de/de/help/images/detect-edges-in-images.html#f11-12512) . Guess you can try those two functions and see which one works better for your data. – The Minion May 15 '14 at 06:51
  • I'm trying to traverse the image, and not a matrix. The minimum and maximum are of the image itself. If I come across an edge (change in intensity i.e.: black to white), I need to find the local min and max of it. I'm trying to use the method researched here; stefan.winklerbros.net/Publications/icip2002.pdf – LahiruAgAr May 15 '14 at 07:11

1 Answers1

0

This is just a summary of my comments. I try to answer your 3) questions given above.

1) There is going to be a nice vectorized way but honestly i ain't sure how that would work. What works is doing it in a loop. For a mxn Matrix it could look like this:

for k=1:m
  for l=1:n
    new_Matrix(k,n-l+1) = old_Matrix(k,l);
  end
end

As is said this isn't the best way to solve it since loops have negative impact on your runtime but they should do the trick.

2) Edge-detection:

BW1 = edge(new_Matrix,'sobel');%//Sobel
BW2 = edge(new_Matrix,'canny');%//Canny-filter

3) min and max-value row-wise

Matrix_transpose = Matrix'; %//transposed matrix
row_wise_min= min(Matrix_transpose);
row_wise_max = max(Matrix_transpose);
The Minion
  • 1,164
  • 7
  • 16
  • This is what I'm trying to do; Convert original image to greyscale image -> generate edge map (which is a binary image) of greyscale image using canny edge detection -> traverse the edge map -> if an edge is found get its local min and max value -> continue searching until I reach the last pixel. – LahiruAgAr May 15 '14 at 07:36
  • The thing is the edge detection results in an image - a binary image. Not a matrix. I need to goto every pixel in the image and check if its an edge. If it is, I need to find the local min and max of that edge separately. Then find the next edge, do the same. This goes on till I reach the final pixel. – LahiruAgAr May 15 '14 at 12:56
  • Matlab is transforming images to matrices. Either a mxnx1 matrix (grayscale) or a mxnx3 matrix for red blue and green (colour) images. Though if you read the binary image into matlab you should be able to process it with the given functions. If you want to take the image as an object and not process it as a matrix you should either think of using the matlab-simulink or another object oriented programming language. At least that would be much easier in my opinion. – The Minion May 16 '14 at 06:28
  • Sorry for taking long to reply. Okay, say I have a matrix of the grey-scale image. Assume I also have the co-ordinates of each edge in the image. There can be more than one edge in each row. Now, I have to calculate the min and max for each edge. Not for the whole row. I know min() and max() can achieve this. But I'm not sure how to apply this. – LahiruAgAr May 23 '14 at 18:46