2017-10-28 1 views
0

저는 Matlab 17.a 프로그램의 이미지 프로세싱 작업을하고 있습니다. 내 작업은 히스토그램 평준화에 관한 것입니다. 코드는 다음과 같습니다. 그러나 코드를 실행할 때 "정의되지 않은 함수 또는 변수 'cumulavite_hist'." 오류가 발생했습니다. 이 문제를 어떻게 수정합니까? 도와 줘서 고마워.정의되지 않은 함수 또는 변수 오류를 수정하는 방법은 무엇입니까?

원본 이미지 옆에 히스토그램이 출력됩니다. 아래는 변화하는 그림과 히스토그램이 될 것입니다. 도와 줘서 고마워.

>> 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) 

답변

0

어서 오세요. comulative_hist 변수가 10 행에 있고 cumulavite_hist 변수가 33 행에 사용되었습니다. 33 행에서 잘못된 이름입니다. 문제가 해결되면 프로그램이 작동합니다.

관련 문제