我编写了一个 MATLAB 程序来渲染 2 个给定图像的“Delta E”或色差图像。但是,当我运行该程序时,我收到此错误:
Error: File: deltaE.m Line: 6 Column: 1
Function definitions are not permitted in this context.
这是程序:
imageOriginal = imread('1.jpg');
imageModified = imread('2.jpg');
function [imageOut] = deltaE(imageOriginal, imageModified)
[imageHeight imageWidth imageDepth] = size(imageOriginal);
% Convert image from RGB colorspace to lab color space.
cform = makecform('srgb2lab');
labOriginal = applycform(im2double(imageOriginal),cform);
labModified = applycform(im2double(imageModified),cform);
% Extract out the color bands from the original image
% into 3 separate 2D arrays, one for each color component.
L_original = labOriginal(:, :, 1);
a_original = labOriginal(:, :, 2);
b_original = labOriginal(:, :, 3);
L_modified = labModified(:,:,1);
a_modified = labModified(:,:,2);
b_modified = labModified(:,:,3);
% Create the delta images: delta L, delta A, and delta B.
delta_L = L_original - L_modified;
delta_a = a_original - a_modified;
delta_b = b_original - b_modified;
% This is an image that represents the color difference.
% Delta E is the square root of the sum of the squares of the delta images.
delta_E = sqrt(delta_L .^ 2 + delta_a .^ 2 + delta_b .^ 2);
imageOut = delta_E;
end
我可能犯了一个初学者的错误,因为我才 17 岁,而且我刚开始使用 MATLAB。如果你能告诉我我做错了什么,那就太好了。