problem with saving image with imwrite!

My code:
load ('cl.dat')
c=reshape(cl,106,14)
ct=transpose(c)
imagesc(ct)
imwrite(ct,'f8.jpg','jpg')
I just want to save the image but it does not work,where is the problem?

Antworten (2)

Image Analyst
Image Analyst am 29 Mai 2013

0 Stimmen

"where is the problem?" - I was going to ask you the same thing. What does "it does not work" mean? Do you have an error message? Are you sure ct is uint8? What does
whos ct
report back?

4 Kommentare

OK, it's double. Try casting to uint8:
ctUint8 = uint8(mat2gray(ct));
and save that instead of ct.
Milenko
Milenko am 29 Mai 2013
Bearbeitet: Image Analyst am 29 Mai 2013
Thanks,it works but this is not exactly what I want.
ctUint8 = uint8(mat2gray(ct));
imagesc(ctUint8)
imwrite(ctUint8,'f8.jpg','jpg')
In ct I have numerical values from 1-8,so I want to represent clusters,image in a way that for one cluster I have one colour.
mat2gray scales to 0-1 so you might need to use
ctUint8 = uint8(255*mat2gray(ct));
if you want it to look bright with a normal gray scale colormap.
Posting an image would help. I don't know what "clusters" means to you. Do you want to do image classification?
Milenko
Milenko am 29 Mai 2013
yes,exactly i want image classification.

Melden Sie sich an, um zu kommentieren.

Milenko
Milenko am 29 Mai 2013

0 Stimmen

>> whos ct Name Size Bytes Class Attributes
ct 14x106 11872 double

Kategorien

Mehr zu Images finden Sie in Hilfe-Center und File Exchange

Tags

Gefragt:

am 29 Mai 2013

Community Treasure Hunt

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

Start Hunting!

Translated by