简体   繁体   English

如何修复未定义的函数或变量错误?

[英]How to fix the undefined function or variable error?

I am working on Matlab 17.a program's image processing. 我正在研究Matlab 17.a程序的图像处理。 My work is about histogram equalization. 我的工作是关于直方​​图均衡化。 The code is as follows. 代码如下。 But when I run the code "Undefined function or variable 'cumulavite_hist'." 但是,当我运行代码“未定义的函数或变量'cumulavite_hist'”时。 I get an error. 我得到一个错误。 How do I fix this problem? 我该如何解决这个问题? Thank you for your help. 谢谢您的帮助。

The output will be the histogram next to the original image. 输出将是原始图像旁边的直方图。 Below it will be the changing picture and histogram. 下面将是变化的图片和直方图。 Thank you for your help. 谢谢您的帮助。

>> img= imread ('C:\Users\emre.guzel\Desktop\homeworkimage.png');
if (size(img,3)>1) 
    img=rgb2gray(img); 
end


max_r = size (img,1);
max_c =size (img,2);
histogram =zeros ([1 256]);
cumulative_hist = zeros ([1 256]);

for r=1:max_r
    for c=1:max_c
        for count =1:256
            if(img(r,c) == count-1 )
                histogram (count) =histogram (count)+ 1;
                break ; 
            end    
        end
    end
end

%find cumulative histogram 
current_value = 0;
for count=1:256
    current_value = current_value + histogram (count);
    cumulative_hist(count) = current_value;
end
%find h =(cdf-cdf(min) / (MN - cdf (min) )) * 255
%this is the normalized cumulative histogram normalize dediğine bakma sen.
%histogram equalization formulu bu . aşağıda da bunu uygulamış.
normalized_hist = zeros ([1 256]);
cdf_min = min (cumulavite_hist) ;
for count = 1:256
    normalized_hist(count) = cumulative_hist(count) - cdf_min;
    normalized_hist(count) = normalized_hist (count) / ((max_r*max_c)- cdf_min);
    normalized_hist(count) = round (normalized_hist (count) * 255);
end
%replace the values with given equalized    values 
equalized_image = zeros ([max_r max_c]);
for r =1:max_r
    for c=1:max_c

        for count = 1:256
            if(img(r,c) ==(count-1))
                %
                %
                equlized_img(r,c) = normalized_hist(count);

                break;
            end
        end
    end
end
subplot(2,2,1)
imshow(img);
title('Orijinal Image');
subplot (2,2,2);
imhist(img) ;
title ('Hist of Orijinal Image');
subplot(2,2,3) ;
imhist (uint8(equalized_img));
title('Histogram Equalized Image');
H = uint (equalized_img);
subplot(2,2,4) ;
imhist(H) ;
title ('Histogram of Histogram Equalized Image');

a = histeq(img);
figure 
imshow(a)

Come on, man. 来吧,伙计 You have comulative_hist variable at line 10 and cumulavite_hist variable used in line 33. It's just wrong name in line 33. Fix it and program will work. 您在第10行有comulative_hist变量,在第33行使用了cumulavite_hist变量。这在第33行是错误的名称。修复它,程序将起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM