MATLAB Answers

How from uint8 to 0 and 1?

3 views (last 30 days)
Dimitrios
Dimitrios on 6 Nov 2014
Commented: Dimitrios on 6 Nov 2014
I import the following image which is a [583x673x3] uint8 :
and i would like the convert the grey/black color to origianally black.How it can be ?

Accepted Answer

Sean de Wolski
Sean de Wolski on 6 Nov 2014
Igray = rgb2gray(I);
BW = im2bw(Igray,graythresh(Igray));
imshow(BW)
  2 Comments
Dimitrios
Dimitrios on 6 Nov 2014
Sorry i deleted the question,because i found it.but thanks for the answer.For others my question was 'How to convert the resulted image again to uint8?'

Sign in to comment.

More Answers (2)

Youssef  Khmou
Youssef Khmou on 6 Nov 2014
Edited: Youssef Khmou on 6 Nov 2014
rgb2gray(im2double(X));
  1 Comment
Dimitrios
Dimitrios on 6 Nov 2014
thank you for your answer, but the image remained the same.

Sign in to comment.


Chad Greene
Chad Greene on 6 Nov 2014
Tinker with this threshold value:
threshold = 250;
A = imread('export_fig_out.png');
A(A>=threshold)=255;
A(A<threshold)=0;
imshow(A)
  2 Comments
Sean de Wolski
Sean de Wolski on 6 Nov 2014
graythresh separates modes for you :)

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!