process bitmap image to mif file

Status
Not open for further replies.

znab18

Newbie level 3
Joined
Jan 15, 2011
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,305
hello...
can anybody please help me?
i have this full program,its work.but then when i want to change the spesific size,it have the error.
-----------------
name = 'image';
img = imread(strcat(name,'.gif'));
g = im2double(img);
g = g/max(max(g));
rgb = cat(3,g,g,g);
imshow(rgb);
out = ones(480,640);
out(10+(1:460),90+(1:460)) = img;
imshow(out);

x = out';
x = uint8(x();
n = length(x);
y = reshape(x,8,n/8)';
z = y,8);
for i=1:7
z = bitor(z,bitshift(y,i),8-i));
end

m = 0;
n = 1;
v = z(1);
for i=2:length(z)
if (z(i)~=v)
m = m + 1;
value(m) = v;
runlen(m) = n;
n = 1;
v = z(i);
else
n = n + 1;
end
end
m = m + 1;
value(m) = v;
runlen(m) = n;

fprintf('total runs %d\n',sum(runlen));
fprintf('number of runs %d\n',length(runlen));
nz = length(find(value==0));
nf = length(find(value==255));
fprintf('zeros %d all ones %d\n',nz,nf);

dfv = 255;
fid = fopen(strcat(name,'.mif'),'w');
str = 'WIDTH=8;\nDEPTH=38400;\n\nADDRESS_RADIX=HEX;\nDAT A_RADIX=HEX;\n\n';
fprintf(fid,str);
str = 'CONTENT BEGIN\n [0000..%04X] : %X;\n';
fprintf(fid,str,sum(runlen)-1,dfv);
n = 0;
for k=1:length(runlen)
if (runlen(k)==1)
str = sprintf(' %04X : %X;\n', n, value(k));
else
str = sprintf(' [%04X..%04X] : %X;\n', n, n+runlen(k)-1, value(k));
end
if (value(k) ~= dfv)
fprintf(fid,str);
end
n = n + runlen(k);
end
fprintf(fid,'END;\n');
fclose(fid);
--------------
can you show me how to make the image 16bits width and 4096bits depth.
my image size is 64x64.
which part should i alter?
thank you.
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…