Hi All
I have this code here
it is for Reading a RAW format gray scale image
[code]
fid = fopen(filename,'rb');
if (fid==1)
error('Cannot open image file...press CTRL-C to exit ');pause
end
temp = fread(fid, nSize, 'uchar');
fclose(fid);
result = reshape(temp, [nRow nColumn])';
Where
input: filename : input file
nSize : size of the output image
nRow : row of the output image
nColumn : column of the output image
output: result : output data in matrix format
###
My Questions are:
1. Filename can be .bmp/.jpg right ? I am using lena ( 128X128)
2. if I give nsize as 128 then what should be filled in [ nrow ncolumn] matrix?
it is giving me errors saying " elements should be same "
PLEASE HELP !!!!
MATLAB CODE FOR Reading a RAW format gray scale image from diskIMAGE PROCESSING
Page 1 of 1
1 Replies - 10214 Views - Last Post: 11 April 2008 - 01:58 AM
#1
MATLAB CODE FOR Reading a RAW format gray scale image from disk
Posted 14 March 2008 - 10:29 AM
Replies To: MATLAB CODE FOR Reading a RAW format gray scale image from disk
#2
Re: MATLAB CODE FOR Reading a RAW format gray scale image from disk
Posted 11 April 2008 - 01:58 AM
The answer to your first question is: No, the files cannot be JPEG or BMP format. The code you provided reads in a series of bytes, which I presume are luminance ("grayscale") values, then re-shapes them into a 2-D array. Formats like JPEG and BMP are much more complicated than this. The good news is that MATLAB can read those as well. Try 'help imread'.
The answer to your second question is that the vector [ nrow ncolumn] is supposed to contain the number of rows and the number of columns. In the case you described, that would be [128 128].
-Will
Data Mining in MATLAB
The answer to your second question is that the vector [ nrow ncolumn] is supposed to contain the number of rows and the number of columns. In the case you described, that would be [128 128].
-Will
Data Mining in MATLAB
Tavisha, on 14 Mar, 2008 - 10:29 AM, said:
Hi All
I have this code here
it is for Reading a RAW format gray scale image
[code]
fid = fopen(filename,'rb');
if (fid==1)
error('Cannot open image file...press CTRL-C to exit ');pause
end
temp = fread(fid, nSize, 'uchar');
fclose(fid);
result = reshape(temp, [nRow nColumn])';
Where
input: filename : input file
nSize : size of the output image
nRow : row of the output image
nColumn : column of the output image
output: result : output data in matrix format
###
My Questions are:
1. Filename can be .bmp/.jpg right ? I am using lena ( 128X128)
2. if I give nsize as 128 then what should be filled in [ nrow ncolumn] matrix?
it is giving me errors saying " elements should be same "
PLEASE HELP !!!!
I have this code here
it is for Reading a RAW format gray scale image
[code]
fid = fopen(filename,'rb');
if (fid==1)
error('Cannot open image file...press CTRL-C to exit ');pause
end
temp = fread(fid, nSize, 'uchar');
fclose(fid);
result = reshape(temp, [nRow nColumn])';
Where
input: filename : input file
nSize : size of the output image
nRow : row of the output image
nColumn : column of the output image
output: result : output data in matrix format
###
My Questions are:
1. Filename can be .bmp/.jpg right ? I am using lena ( 128X128)
2. if I give nsize as 128 then what should be filled in [ nrow ncolumn] matrix?
it is giving me errors saying " elements should be same "
PLEASE HELP !!!!
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote



|