フィルターのクリア

Is there a way to get a "thicker" bwconncomp connection?

4 ビュー (過去 30 日間)
Naim
Naim 2017 年 6 月 19 日
編集済み: Gopichandh Danala 2017 年 6 月 20 日
See attached image. I have a stack of similar images and I want to remove the large white spaces on the top, bottom, and left of the image.
I used the code:
CC = bwconncomp(BW)
numPixels = cellfun(@numel,CC.PixelIdxList);
[biggest,idx] = max(numPixels);
BW(CC.PixelIdxList{idx}) = 0;
but this sets almost the entire picture black. I suspect it is because there is a little touching between the whites, I want matlab to only pick up the obvious white spaces on the sides. What am i doing wrong?
  1 件のコメント
Gopichandh Danala
Gopichandh Danala 2017 年 6 月 20 日
can you upload the original image

サインインしてコメントする。

回答 (1 件)

Gopichandh Danala
Gopichandh Danala 2017 年 6 月 20 日
編集済み: Gopichandh Danala 2017 年 6 月 20 日
If you are just trying to replace all the white pixels in the surroundings to 0, all the connected white valleys on the edges also get removed.
img = rgb2gray(imread('image.png'));
BW = bwlabel(img); % based on labelling algorithm the left top is '1' so backgrounf label is '1'
img(BW == 1) = 0; % replace this label pixels in image to 0
figure, imshow(img);

Community Treasure Hunt

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

Start Hunting!

Translated by