Discontinue processing on edge pixels within an image

I have enhanced the edge information within an image. Now I want another algorithm to work on the rest of the image information excluding edges. I am taking small image blocks at a time on which the algorithm is going to be applied. How can I make this algorithm to work on the rest of the image information and not on edges? Should I define a fixed width for edges and brute force the algorithm to not work on pixels of "this much" width or "intensity". That wouldn't be robust, right? Any ideas would be appreciated.

 Réponse acceptée

Well there are two ways.
  1. You could process the whole image and then just replace the edge pixels of the output image with the original pixels. This is by far the easiest.
  2. You could try to not use the pixels in the processing in the first place by setting them to 0 or nan or some other flag value. How you handle it really depends on what king of processing takes place.
To do the first way, just have your mask of edge pixels, then do
outputImage(mask) = originalImage(mask);

6 commentaires

mona
mona le 28 Déc 2014
Thank you so much. Just one question regarding the second option, if I set the edge pixels to NaN, would they be ignored by the algorithm?
It depends on what kind of functions you use. With many/most functions if you take a bunch of values that have one of more nan's in them, and do an operation with them then you will get a nan out. For example sum() and mean(). For others, like max() and min(), having a nan in there is fine - it ignores them.
mona
mona le 28 Déc 2014
I have to take the average of certain set of pixels and then find the median value for the pixels falling above as well as below the average separately. I feel computing average can have some problem here. What do you think?
There is a nanmean() function that ignores means - I think it's in the Statistics Toolbox. But you can do it with isnan() easily:
% Sample data.
a = [3, nan, 5];
% Get a version of a that has no nan's in it.
aNoNan = a(~isnan(a))
% Now get mean and median with that.
theMean = mean(aNoNan(:))
theMedian = median(aNoNan(:))
mona
mona le 30 Déc 2014
Amazing. Thanks alot
Actually there is a setting in R2014b that lets you specify whether nan's are included or ignored in calculations. Look in Home->Preferences>Workspace->Statistical Calculations

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by