如何用matlab把RAW格式图像提取并转换成灰度图像?
Y=0.21R+0.72G0.07BY给了个公式小弟是初学者,有很多问题,恳请大家帮忙!Y=0.21r+0.72g+0,07b上面那个公式错了谢谢您的帮助,就是原始的ra...
Y = 0.21 R + 0.72 G 0.07 BY
给了个公式
小弟是初学者,有很多问题,恳请大家帮忙!
Y=0.21r+0.72g+0,07b
上面那个公式错了
谢谢您的帮助,就是原始的raw数据,老师就是想让我们自己来编方法所以不让我们用直接读的函数,下面是他给的一些允许用的函数,您帮忙看看给点建议,我还是不知道该怎么实现
图像是400*300,,24bit的
function G = readraw(filename)
%readraw - read RAW format grey scale image of square size into matrix G
% Usage: G = readraw(filename)
disp([' Retrieving Image ' filename ' ...']);
% Get file ID for file
fid=fopen(filename,'rb');
% Check if file exists
if (fid == -1)
error('can not open input image file press CTRL-C to exit \n');
pause
end
% Get all the pixels from the image
pixel = fread(fid, inf, 'uchar');
% Close file
fclose(fid);
% Calculate length/width, assuming image is square
[Y X]=size(pixel);
Size=(Y*X);
N=sqrt(Size);
% Construct matrix
G = zeros(N,N);
% Write pixels into matrix
G(1:Size) = pixel(1:Size);
% Transpose matrix, to orient it properly
G = G';
end %function 展开
给了个公式
小弟是初学者,有很多问题,恳请大家帮忙!
Y=0.21r+0.72g+0,07b
上面那个公式错了
谢谢您的帮助,就是原始的raw数据,老师就是想让我们自己来编方法所以不让我们用直接读的函数,下面是他给的一些允许用的函数,您帮忙看看给点建议,我还是不知道该怎么实现
图像是400*300,,24bit的
function G = readraw(filename)
%readraw - read RAW format grey scale image of square size into matrix G
% Usage: G = readraw(filename)
disp([' Retrieving Image ' filename ' ...']);
% Get file ID for file
fid=fopen(filename,'rb');
% Check if file exists
if (fid == -1)
error('can not open input image file press CTRL-C to exit \n');
pause
end
% Get all the pixels from the image
pixel = fread(fid, inf, 'uchar');
% Close file
fclose(fid);
% Calculate length/width, assuming image is square
[Y X]=size(pixel);
Size=(Y*X);
N=sqrt(Size);
% Construct matrix
G = zeros(N,N);
% Write pixels into matrix
G(1:Size) = pixel(1:Size);
% Transpose matrix, to orient it properly
G = G';
end %function 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询