How can i change places to pixel values(black ones to white, white ones to black) of binary image?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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;
0 commentaires
Réponses (1)
Athul Prakash
le 30 Avr 2020
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!
2 commentaires
Athul Prakash
le 30 Avr 2020
Alternatively, you may use the imcomplement function. Please read the doc below:
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!