Remove outlier pixels after edge detection

9 views (last 30 days)
Papaya
Papaya on 12 Jan 2020
Answered: Image Analyst on 20 Jan 2020
I super-impose pixels found from [ Y, X]=find(BW==1), where BW is after the edge() function of a a snapshot image of a lip captured via a webcam . But there are some outlier pixels as shown. The outlier pixels are obvious when the the webcam Brightness is set to example cam.Brightness=180. Could someone suggest how should I get ride of the outlier pixles if I need to retain the Brightness setting.
My codes:
mouthImgGray=rgb2gray(I2); %%%I2 is the RGB of a lip image
BW = edge(mouthImgGray,'Sobel','horizontal');
[ Y, X]=find(BW==1);
imshow(I2);
hold;
plot( X, Y,'.');
  1 Comment
Meg Noah
Meg Noah on 12 Jan 2020
easiest way ('cheating') is to just set those values to zero
BW(iline1:iline2,:)=0;
or try a
labeled = bwlabel(BW);
stats = regionprops(labeled,mouthImgGray,'ALL');
then look at stats to see how to eliminate blobs - looping through the blobs if the blob size/area is too big or small, or if the blob min/max pixel value is out of the region of interest:
labeled(iblob)=0;

Sign in to comment.

Answers (2)

Raunak Gupta
Raunak Gupta on 20 Jan 2020
Hi,
I assume the main objective is to detect the edges of lips in the snapshot image. I suggest increasing the sharpness by using any of method mentioned in Contrast Adjustment. Also, you may try using the threshold option within edge function within different edge detection method. Since here edge detection is tried, if the image contains a gradient anywhere it will appear as an edge so removing outlier is not possible. Also finding connected components will also not help since the edges are not connected in any sense. By sharpening the image and putting a threshold you may avoid the outliers in first place.

Image Analyst
Image Analyst on 20 Jan 2020
You can just scan across and find if the distance between the top point and the bottom point is too much, like more than 50 lines or whatever.
[rows, columns] = size(BW);
goodColumns = false(1, columns);
for col = 1 : columns
row1 = find(BW(:, col), 1, 'first')
row2 = find(BW(:, col), 1, 'last')
heights(col) = row2 - row1;
if heights(col) < 50 % Whatever...
% Top and bottom are reasonably close to each other.
goodColumns(col) = true;
end
end
outlierColumns = ~goodColumns; % Bad columns are the opposite of good columns of course.
However that will not tell you what the location SHOULD be.

Products

Community Treasure Hunt

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

Start Hunting!