Forums

pixel values

Started by heidar mhr January 29, 2007
Hello guys,

I have a question. I have an image and I am wondering how to use MATLAB to generate a text file that contains the pixel values of the image?

Thanks

Haidar
Hi Haidar,
u can proceed the steps:

x = imread('\'); % pixel values
imshow(x) % to show the image in MATLAB

now x is ur pixel values of the image.
On 1/28/07, heidar mhr wrote:
>
> Hello guys,
>
> I have a question. I have an image and I am wondering how to use MATLAB to
> generate a text file that contains the pixel values of the image?
>
> Thanks
>
> Haidar
>
>
Open the read matrix (image) in array editor in Matlab. Then copy and paste whole matrix into a notepad.
--- In m..., Naveen wrote:
>
> Open the read matrix (image) in array editor in Matlab. Then copy
and paste whole matrix into a notepad.

>

alternatively for automatic transfer write to a file using the fopen
and fprintf commands so something like

im = imread('myimage');
fid = fopen('mytxtfile.txt', 'w+');
for i=1:numel(im)
fprintf(fid, '%c\t', im(i));
end

It's slightly more complicated than that depending on whether you
just want the values or whether you also want the structure of the
image (i.e. maintaining rows and columns).

hth