how to set colors for regions in an image?
조회 수: 1 (최근 30일)
이전 댓글 표시
i have to set different colors for different regions in a same image. In the first step i have calculated the intensity for all pixel using parzen density formula.
Next i had found the neighbour pixel and location having higher intensity value in 8-coordinated size for all pixels in the image. Now i have an variable having locations of maximum pixel of all pixels. i need to give same color for similar location. can anyone help me.. i have given my coding i have done yet.What corrections i have to do?
I=im2double(imread('horse1.bmp'));
I=rgb2gray(I);
imshow(I),figure;
M=[1 1 1;1 1 1;1 1 1]./9;
A=(exp(-((I-conv2(I,M,'same')).^2)./18));
I=(1/2*pi*9).*A;
D = padarray(I,[1 1],0,'both');
s = size(I);
N = padarray(reshape(1:numel(I),s),[1 1],0,'both');
pt = [1 1 1;1 0 1;1 1 1] > 0;
s1 = s+2;
out = zeros(s);
for i=2:s1(1)-1
for j=2:s1(2)-1
D1 = D(i-1:i+1,j-1:j+1);
K = N(i-1:i+1,j-1:j+1);
K = K(pt);
[~,i0] = max(D1(pt));
out(i-1,j-1) = K(i0);
end
end
s=[5,5];
[R C]=ind2sub(s,out);
댓글 수: 0
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Blue에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!