How to loop on a data cube of an image
Mostrar comentarios más antiguos
Hi, I'm trying to calculate gradient at each pixel in a data cube of an image an i'm getting this error "index out of bounds because size(X)=[280,307,191]."
Any help would be much appreciated Thank you
2 comentarios
Walter Roberson
el 7 de Abr. de 2013
We are going to need to see some of your code.
Rawan hamdi
el 8 de Abr. de 2013
Editada: Walter Roberson
el 8 de Abr. de 2013
Respuesta aceptada
Más respuestas (2)
Walter Roberson
el 8 de Abr. de 2013
You establish x, y, and bands according to the content of the noisy image, but then your triple nested for loop has you looping using those values as indices, such as in
for i = 1:1: x
Question: in your line
current_grad(i,j,k) = gradient(i,j,k);
is "gradient" the gradient function? If so then why are you applying the function to the indices i, j, k, rather than to the content of the image? And does it make sense to be applying the gradient function only to a point at a time?
8 comentarios
Rawan hamdi
el 8 de Abr. de 2013
Image Analyst
el 8 de Abr. de 2013
Then why are you not using imgradient() or imgradientxy() on each spectral band?
Rawan hamdi
el 8 de Abr. de 2013
Walter Roberson
el 8 de Abr. de 2013
imgradient() is part of the Image Processing Toolkit. That toolkit is included with Student Version licenses but is not installed by default.
Image Analyst
el 8 de Abr. de 2013
You must have a really old version. Does your license include upgrades? If so, do it.
Rawan hamdi
el 8 de Abr. de 2013
Walter Roberson
el 8 de Abr. de 2013
Which MATLAB version are you using? And are you using the Student license?
Image Analyst
el 8 de Abr. de 2013
I cannot help you do the upgrade. You'll have to contact the Mathworks to do that.
Rawan hamdi
el 8 de Abr. de 2013
Editada: Walter Roberson
el 8 de Abr. de 2013
2 comentarios
Walter Roberson
el 8 de Abr. de 2013
You establish x, and y according to the content of the noisy image, but then your triple nested for loop has you looping using those values as indices.
Also, you are overwriting G in each iteration of the triple-nested loop.
Rawan hamdi
el 8 de Abr. de 2013
Categorías
Más información sobre Image Processing Toolbox en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!