Replace ROI with variable texture

2 visualizaciones (últimos 30 días)
Adrian Szatmari
Adrian Szatmari el 26 de Ag. de 2017
Comentada: Image Analyst el 28 de Ag. de 2017
Hi! I would like to know whether someone has a better way of doing the following. I have a grayscale image IMG and a certain ROI specified by the (n x 2) index data INDEX, where n is the number of points in the ROI, thus naturally INDEX(i,1) = xi and INDEX(i,2) = yi, i = 1, ..., n. Moreover for each corresponding i-th point, a value is specified in a (n x 1) vector TEXTURE, so that TEXTURE(i) is the value of point (xi, yi). Naturally I want to fill in the IMG with the values in TEXTURE. The following works:
for i = 1:length(INDEX)
x = INDEX(i,1);
y = INDEX(i,2);
IMG(x,y) = TEXTURE(i);
end
Is there a better way of doing this? Maybe without a for loop?
Thanks in advance! Please criticise.

Respuesta aceptada

Image Analyst
Image Analyst el 26 de Ag. de 2017
That way is fine except for one thing: you need to swap x and y because you made the common novice mistake of thinking (x,y) is (row, column). It is NOT. Do this:
IMG(y, x) = TEXTURE(i);
  2 comentarios
Adrian Szatmari
Adrian Szatmari el 27 de Ag. de 2017
Thanks for the feedback, I went ahead and fixed the x, y issue. That being said I am doing this texturing millions of times, I thought maybe there was a more native way of doing it.
Image Analyst
Image Analyst el 28 de Ag. de 2017
There probably is, but since I don't have your images, I can't really tell what you want to do. I don't really know what Texture is. For example, do you have a texture image and a gray scale image and you want to replace the gray scale image in some ROI with the texture image? I can't really tell when all you give me is some code that you say does NOT do what you want.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Images en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by