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 中查找有关 3-D Volumetric Image Processing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!