Info
La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.
I have executed a code and it seem to give errors. Is there any invalid statements? The image is of [r x c] = 256 X 256 and I tried to store each co-ordinate {(1,1),(1,2),...,(256,256)} corresponding to each pixel value in an array 'C'.
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
I = imread('Cameraman.tif');
[r,c] = size(I);
k = 1;
loop to store the pixel co-ordinates
for i = 1:r;
for j = 1:c;
C(k,:) = [i,j];
k = k + 1;
end
end
Expected should be: When I type C(10,10), it should return the pixel value corresponding the resp co-ordinate.
1 comentario
Stephen23
el 22 de Mzo. de 2016
Editada: Stephen23
el 22 de Mzo. de 2016
You already imported the image as an array I, so why not just access it directly?, e.g.:
pixval = I(10,10,:)
Good programmers try to keep their code as simple as possible, because this makes it faster, more robust, and easier to test, easier to undestand, easier to write, easier to fix...
Why bother indirectly accessing the pixels when you can index into the image directly?
Your proposal "When I type C(10,10), it should return the pixel value corresponding the resp co-ordinate" can be achieved in one step using num2cell, but this is a total waste of time.
Respuestas (0)
La pregunta está cerrada.
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!