How to convert RGB image to Luminance image and store the image as .raw file in Matlab -


i trying convert rgb image luminance image , save .raw image use in software. using following code

m = imread('20x20-alpha1-1.jpg'); out = zeros(1942,2588); i=1:1942    j=1:2588     out(i,j) = 0.2126*m(i,j,1) + 0.7152*m(i,j,2) + 0.0722*m(i,j,3);    end end fileid = fopen('20x20-alpha1-1.raw'); fwrite(fileid,out); fclose(fileid); 

however, when try open image irfanviewer, file said corrupted. problem in code ? if how can convert image luminance image , save ? thank :)

there no need mess around .raw files in case. write tiff file instead:

imwrite(out,'20x20-alpha1-1.tiff','tiff') 

Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -