URL
https://opencores.org/ocsvn/mkjpeg/mkjpeg/trunk
Subversion Repositories mkjpeg
Compare Revisions
- This comparison shows the changes necessary to convert path
/mkjpeg
- from Rev 8 to Rev 9
- ↔ Reverse comparison
Rev 8 → Rev 9
/branches/main/tb/matlab/img2txt.m
0,0 → 1,48
filename='test'; |
filenamet=strcat(filename,'.txt'); |
|
I = imread(filename,'bmp'); |
|
IYUV=rgb2ycbcr(I); |
|
fid = fopen(filenamet,'w+'); |
[X,Y,Z] = size(I); |
fprintf(fid, '%d\n',Z); % number of image components |
fprintf(fid, '%d\n',X); % lines |
fprintf(fid, '%d\n',Y); % pixels in line |
for x = 1:X |
for y = 1:Y |
for z = 1:Z |
R = int16(I(x,y,1)); |
G = int16(I(x,y,2)); |
B = int16(I(x,y,3)); |
% Y |
if z == 1 |
sample = (0.299*R)+(0.587*G)+(0.114*B); |
% Cb |
elseif z == 2 |
sample = (-0.1687*R)-(0.3313*G)+(0.5*B)+128; |
% Cr |
elseif z == 3 |
sample = (0.5*R)-(0.4187*G)-(0.0813*B)+128; |
end |
if sample > 255 |
sample = 255; |
elseif sample < 0 |
sample = 0; |
end |
ID(x,y,z) = sample; |
|
%sample = IYUV(x,y,z); |
sample = I(x,y,z); |
|
if sample < 16 |
fprintf(fid, '0%x', double(sample)); |
else |
fprintf(fid, '%x', double(sample)); |
end; |
end; |
end; |
fprintf(fid,'\n'); |
end; |
fclose(fid); |
/branches/main/tb/matlab/txt2img.m
0,0 → 1,47
clear |
fid = fopen('test.txt','r+'); |
|
line = fgetl(fid); |
uns16 = sscanf(line, '%d'); |
num_comp = double(uns16); |
|
line = fgetl(fid); |
uns16 = sscanf(line, '%d'); |
y_size = double(uns16); |
line = fgetl(fid); |
uns16 = sscanf(line, '%d'); |
x_size = double(uns16); |
|
for y = 1 : y_size , |
for x = 1 : x_size , |
for z = 1 : num_comp |
signed = fscanf(fid, '%2x',1); |
E(y,x,z) = uint8(signed); |
end |
end |
end |
|
imwrite(E, 'imageo.jpg','jpg','Quality',100); |
fclose(fid); |
|
return; |
%%%%%%%%%%%%%%% |
clear |
fid = fopen('imagee.txt','r+'); |
|
line = fgetl(fid); |
uns16 = sscanf(line, '%d'); |
y_size = double(uns16); |
line = fgetl(fid); |
uns16 = sscanf(line, '%d'); |
x_size = double(uns16); |
|
for y = 1 : y_size , |
for x = 1 : x_size , |
signed = fscanf(fid, '%2x',1); |
E(y,x) = uint8(signed); |
end |
end |
|
imwrite(E, 'imagee.jpg','jpg'); |
fclose(fid); |
/branches/main/tb/matlab/test.bmp
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
branches/main/tb/matlab/test.bmp
Property changes :
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property