Rgb2ind value coding problem

2 visualizaciones (últimos 30 días)
Akmal Rahmat
Akmal Rahmat el 27 de Nov. de 2014
Comentada: Image Analyst el 30 de Nov. de 2014
Hello all. I have some question. i have an image, i read the image using imread after that i convert it to index image using rgb2ind. Then i save it into text file(.txt). why the value in the text file only 0 and 1 ? does it supposed to show range of value from 0-255 ?
a = imread('img1.jpg');
[b,map]=rgb2ind(x,32);
prewitts=edge(b,'prewitt');
dlmwrite('test1.txt', prewitts, 'delimiter', ',');
im using this code. also attach the image and the text file.

Respuesta aceptada

Guillaume
Guillaume el 27 de Nov. de 2014
It has nothing to with rgb2ind and everything to do with edge.
As per the documentation of edge, it returns a binary image BW of the same size as I, with 1's where the function finds edges in I and 0's elsewhere.
Moreover, since you pass 32 to rgb2ind, the values in b will be in the range 0-31, not 0-255.
Do read the documentation, it's all in there.
  2 comentarios
Akmal Rahmat
Akmal Rahmat el 28 de Nov. de 2014
Thank you. So i need to pass to rgb2ind value to 255 ?
Guillaume
Guillaume el 28 de Nov. de 2014
To get 256 values (0-255) out of rgb2ind you need to pass 256
This does not change the fact that edge will always return a binary image (0s and 1s)

Iniciar sesión para comentar.

Más respuestas (1)

Image Analyst
Image Analyst el 28 de Nov. de 2014
If, for some reason, you want 0 and 255, you could just multiply by 255:
prewitts = uint8(255 * edge(b,'prewitt'));
  2 comentarios
Akmal Rahmat
Akmal Rahmat el 30 de Nov. de 2014
Editada: Akmal Rahmat el 30 de Nov. de 2014
but sir.my text file data is 0 and 1 only. If I multiply it , only the value 1 will change. How do I change the whole data to 0-255 range of value even it goes through process like sobels.
Image Analyst
Image Analyst el 30 de Nov. de 2014
You're right that 1, multiplied by 255, will show up as 255 in the text file. But what value do you want the zero to show up as in your text file?

Iniciar sesión para comentar.

Categorías

Más información sobre Images en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by