Calculate mean value on a skeleton of an image

1 visualización (últimos 30 días)
Alyssa Webb
Alyssa Webb el 23 de Feb. de 2017
Comentada: Alyssa Webb el 26 de Feb. de 2017
Hi everyone! I'm working on a skeleton of an image and I found some errors on it. I marked them with ones, so I can identify them easily. I had introduced data in the positions of the original skeleton, that's why most of the values are different to 1 and 0. I'd like to change the value of the ones by the mean value of the 3x3 neighbours of that position, that are different to 0 or 1. For example:
A = [0 0 0 265 0 ; 0 1 260 0 0 ; 0 250 0 0 0 ; 251 250 0 0 0 ; 251 0 0 0 0];
I'd like to change the 1 by 255, the mean (average) value of 260 and 250 (neighbours of 1 and with a different value of 1 and 0).

Respuesta aceptada

Image Analyst
Image Analyst el 23 de Feb. de 2017
What is A? The modified skeleton or the original image? A skeleton is a binary image of type logical. Ignoring your A, what I'd do is this:
% Blur image
blurredImage = conv2(double(grayImage), ones(3)/9, 'same');
% Replace image "B" with values of the blurred image at the location of the skeleton 1 values:
B(skelImage) = blurredImage(skelImage);
That's the best I can do because I can't follow what you're saying. You have a gray scale image, a logical skeleton image, and you even have a third image that I guess is the skeleton image converted from logical to gray scale and some "data" from the gray scale image has replaced some pixels (or something like that). So, with these 3 images, you only give the one, very-badly-named "A" image, and don't say exactly what it is. Please give all 3 matrices plus a fourth one that is your desired output image.
  3 comentarios
Image Analyst
Image Analyst el 24 de Feb. de 2017
OK, let's say the ground height image is called heightImage, rather than something bad like "B". So you'd do :
% Blur original height image
blurredImage = conv2(double(heightImage), ones(3)/9, 'same');
% Find out where the 1's in "A" live:
onesLocations = A == 1;
% Replace image "A" with values of the blurred image at the location of A's 1 values:
A(onesLocations) = blurredImage(onesLocations);
Alyssa Webb
Alyssa Webb el 26 de Feb. de 2017
Thank you so much!

Iniciar sesión para comentar.

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by