1
votes

MATLAB code included for reference below. The pixel value displayed is 153 199 215. I can calculate the norm (330.5072) using the norm function in the MATLAB command line. However, when I run the code below, upon reaching the norm function, MATLAB errors with "Undefined function 'norm' for input arguments of type 'uint8'".

for i = 1:length(centers)
    center = round(centers(i,:));
    disp(center);
    pixel = rgb(center(1), center(2),:);
    pixel = [pixel(1,1,1) pixel(1,1,2) pixel(1,1,3)];
    disp(pixel);
    n = norm(pixel);
1

1 Answers

1
votes

MATLAB's 'norm' function does not take uint8 data as an argument. Cast pixel to a double using

pixel = double(pixel);

before calling the norm function, and the code runs without error.