# how to set colors for regions in an image?

1 visualizzazione (ultimi 30 giorni)
sheno39 il 24 Ott 2013
Modificato: Walter Roberson il 24 Ott 2013
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=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;
s = size(I);
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 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Categorie

Scopri di più su Colormaps in Help Center e File Exchange

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by