How can i change places to pixel values(black ones to white, white ones to black) of binary image?

3 ビュー (過去 30 日間)
Zuy
Zuy 2020 年 4 月 24 日
コメント済み: Zuy 2020 年 5 月 2 日
Hello,
How can i change black pixels to white and white pixels to black of my image?
I am trying this code but i get an error
I = imread('Deneme_10.png');
Igray=rgb2gray(I);
BW=imbinarize(Igray);
BW2 = imfill(BW,'holes');
BW3 = bwareaopen(BW2,8000);
BW3(BW3==0)=1 && BW3(BW3==1)=0;

回答 (1 件)

Athul Prakash
Athul Prakash 2020 年 4 月 30 日
Hey Zuy,
I don't think you can concatenate statements in matlab using '&&' - that is a logical operator, the kind that is used mostly within an if condition. I presume that the error you are receiving is related to that; please try to post the actual error message when you ask a question on the community so that we can understand your problem better. This should increase your chances of getting a response manifold, in my experience.
Here's a solution you can try out:
You need to use a copy of the image before changing colors, otherwise you'll be overwriting the first change when you make the second one, and produce all 0's (or all 1's).
% 'I' hold the binarized image.
temp = I;
I(temp==1)=0;
I(temp==0)=1;
Hope it Helps!

カテゴリ

Help Center および File ExchangeImages についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by