Grouping the pixel having same values

16 visualizaciones (últimos 30 días)
kash
kash el 23 de Ag. de 2012
I have a RGB image in which i have taken some pixel values for example
83 81 81 84 85 84 82 82 84 81 83 83 81 81
83 81 81 83 83 82 80 81 83 80 82 83 81 79
81 79 83 84 84 84 81 81 82 80 81 81 79 79
79 80 82 86 85 84 83 83 85 85 81 81 79 79
79 81 84 85 85 83 83 83 84 83 81 83 81 81
84 83 84 85 85 83 84 80 81 81 81 82 82 83
83 84 86 85 85 83 84 80 79 80 82 82 81 83
for exmaple first value is 83,neighbour value is also 83 so it must be grouped(2 values will be grouped),next value 81(4 values of 81 it must be grouped )then next value is 85 there is no other neighbour value of 85 so it must be grouped as single vaue(1 value will be there),please help how to process
the pixel having same neighbour values must be grouped
please help
  1 comentario
Image Analyst
Image Analyst el 23 de Ag. de 2012
Define grouped. The bwconncomp or bwlabel function will do connected components labeling, but then what are you going to do with, say, 256 images of the groups?

Iniciar sesión para comentar.

Respuesta aceptada

Andrei Bobrov
Andrei Bobrov el 23 de Ag. de 2012
Editada: Andrei Bobrov el 23 de Ag. de 2012
I =[83 81 81 84 85 84 82 82 84 81 83 83 81 81
83 81 81 83 83 82 80 81 83 80 82 83 81 79
81 79 83 84 84 84 81 81 82 80 81 81 79 79
79 80 82 86 85 84 83 83 85 85 81 81 79 79
79 81 84 85 85 83 83 83 84 83 81 83 81 81
84 83 84 85 85 83 84 80 81 81 81 82 82 83
83 84 86 85 85 83 84 80 79 80 82 82 81 83 ];
d = unique(I);
out = [];
for jj = 1:numel(d)
r = bwconncomp(I == d(jj),4);
out = [out;[repmat({d(jj)},r.NumObjects,1) r.PixelIdxList']];
end
or
d = unique(I);
out = [];
for jj = 1:numel(d)
s=regionprops(bwconncomp(I == d(jj),4),'PixelList');
out = [out;[repmat({d(jj)},numel(s),1) {s.PixelList}']];
end
[ii,ii] = sortrows(cell2mat(cellfun(@(x)x(1,:),out(:,2),'un',0)),[2 1]);
out = out(ii,:);
  3 comentarios
Walter Roberson
Walter Roberson el 29 de Ag. de 2012
Please show class(out) and size(out) when the error occurs.
kash
kash el 29 de Ag. de 2012
class(out) is cell
and size(out) 49 2

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by