ISP_matlab

确定输入是否为结构体数组字段 - MATLAB isfield- MathWorks 中国

*.对话框打开文件,获取路径和文件名

[file, path] = uigetfile({'*.raw'; '*.RAW'});

fid = fopen(fullfile(path, file));

% https://www.jianshu.com/p/fb17c3c7e3ae
rawData = fread(fid, [width height], 'uint16', 'ieee-le');  % 'uint8' 大端:'ieee-be'

*.读取raw图(解析raw数据头)

        fin = fopen(imgpath, 'r');
        if strcmpi(im.type, 'bin')
            wh = fread(fin, 2, format);
            im.rawWidth = wh(1);
            im.rawHeight = wh(2);
        end
        
        img_raw = [];
        img = [];
        img_raw = fread(fin, im.rawWidth*im.rawHeight, format);
        fclose(fin);
        img = reshape(img_raw, im.rawWidth, im.rawHeight);
        img = img';

*.获取raw图各通道数据;RGGB

% 方法一
    outR  = in(1:2:end, 1:2:end);  % (1, 1)
    outB  = in(2:2:end, 2:2:end);  % (2, 2)
    outG1 = in(1:2:end, 2:2:end);  % (1, 2)
    outG2 = in(2:2:end, 1:2:end);  % (2, 1)


% 方法二
[height, width] = size(img);

CH = [];
CH(:, :, 1) = img(1:2:height, 1:2:width);  % upper left;
CH(:, :, 2) = img(1:2:height, 2:2:width);  % upper right
CH(:, :, 3) = img(2:2:height, 1:2:width);  % lower left
CH(:, :, 4) = img(2:2:height, 2:2:width);  % lower right


combinedImg(1:2:height, 1:2:width) = channel(:, :, 1);
combinedImg(1:2:height, 2:2:width) = channel(:, :, 2);
combinedImg(2:2:height, 1:2:width) = channel(:, :, 3);
combinedImg(2:2:height, 2:2:width) = channel(:, :, 4);

*.convn操作注意

ISP_matlab_第1张图片

你可能感兴趣的:(ISP,isp)