Populating a matrix with pixel values
- From: "m. k" <mkawika@xxxxxxxxxxxxx>
- Date: Tue, 31 Jul 2007 17:04:56 +0000 (UTC)
Hello everyone.
I have a question, and I hope that someone out there can help me out. I am trying to use for loops to populate a matrix with pixel values from a given image.
Given an image, and an x and y coordinate, I want to generate a 5x5 matrix centered on (x,y), populated by pixel intensity values from the image.
A sample of my code:
for a = 0:6
matrix(r,:)=image((y+2)-a, (x-2):(x+2));
a=a+1;
end
Where matrix is the 5x5 matrix that I am trying to generate.
As you can see from the above code, I want to generate a 5x5 matrix, populating each matrix row wise, with the pixel intensity of the image based upon changing the coordinates. However, whenever I run this section of code in MatLab, the error i receive says:
??? Error using ==> image
Incorrect number of arguments specified.
Error in ==> generatematrix at 21
clutter7(r,:)=image((y+3)-a,(x-3):(x+3));
I'm assuming that this message means that MatLab does not allow the image(x,y) command to retrieve information using the ':' operator. Am I wrong in this assumption? Does anybody knows if there is another way to automatically generate this matrix through the use of a for loop or some other operator?
.
- Follow-Ups:
- Prev by Date: Re: Writing formatted text files when column number of the ouput is uncertain?
- Next by Date: Re: Populating a matrix with pixel values
- Previous by thread: Simulink Simple Question
- Next by thread: Re: Populating a matrix with pixel values
- Index(es):