フィルターのクリア

convert the image to binary

7 ビュー (過去 30 日間)
Md
Md 2022 年 9 月 21 日
コメント済み: Image Analyst 2022 年 9 月 21 日
I need to convert the first image to the second image. I posted about this before but the answers didn't help. One of my classmate suggested me to do this (he said that repeat bwareopen and medfilt2 a few time at the end, no specific number), but it didn't help:
RGB=imread("center.jpg");
a=medfilt3(RGB);
b=rgb2gray(a);
c=medfilt2(b);
d=imbinarize(c);
e=medfilt2(d);
imshow(e);
f=bwareaopen(e,1);
g=medfilt2(f);
h=bwareaopen(g,1);
i=medfilt2(h);
imshow(i);
j=bwareaopen(i,1);
k=medfilt2(j);
l=bwareaopen(k,1);
m=medfilt2(l);
Can I get any suggestions? Thank you!
  2 件のコメント
Walter Roberson
Walter Roberson 2022 年 9 月 21 日
I need to convert this image to a clear binary image
Your code already converts to a "clear binary image" -- at least at least as much as you have defined "clear". Which is to say that since you did not indicate how "clear" is to be determined, any binary image satisfies the requirement.
Md
Md 2022 年 9 月 21 日
I need the image to be like this.

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

回答 (1 件)

Walter Roberson
Walter Roberson 2022 年 9 月 21 日
移動済み: Image Analyst 2022 年 9 月 21 日
filename = 'https://www.mathworks.com/matlabcentral/answers/uploaded_files/1131025/image.jpeg';
RGB = imread(filename);
BW = all(RGB<64, 3);
imshow(BW)
center_only = bwareafilt(BW, 1);
imshow(center_only)
center_select = RGB .* uint8(center_only(:,:,[1 1 1]));
imshow(center_select)
That last image does not look like much, but it is the RGB of only the center line, with everything else set to 0. Maybe if we try
center_select2 = imcomplement(RGB) .* uint8(center_only(:,:,[1 1 1]));
imshow(center_select2)
This is an RGB image in "reverse color" in the center. Because the center that you are interested in happens to be dark.
Your target image has grayscale end-caps, but your source image has no end-caps. This last image, center_select2 would pull out grayscale if it meaningfully existed there.
  2 件のコメント
Md
Md 2022 年 9 月 21 日
移動済み: Image Analyst 2022 年 9 月 21 日
Thanks a lot!
Image Analyst
Image Analyst 2022 年 9 月 21 日
@Md Please click the "Accept this answer" link to award @Walter Roberson reputation points. Thanks in advance. 🙂

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

カテゴリ

Help Center および File ExchangeConvert Image Type についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by