PDA

View Full Version : Matlab Question(About matrix sampling)


miyakooo
Nov22-09, 04:46 PM
Hi, y'all!

I'm trying to figure out how to do this MATLAB project for school.
We're required to read in an image and then sample random regions(square, matrix-shaped) of it.

I read in the image and it is formed by a lot of numbers(pixels?), and I determined how to generate a random integer that will index to a random point of the image. I know I am supposed to generate a matrix with the random point in its center, but I am clueless as to how to generate a e matrix-shaped region of an image with a designated center...any ideas? Help me please!

Thanks:)
Miyakooo

MRFMengineer
Nov24-09, 12:11 PM
If you have your random index values, say i and j, why don't you use them to subsample your matrix? p = 1/2 subsample region in pixels

submatrix = image((i-p):(i+p), (j-p):(j+p))
This should give a submatrix with center i, j, with size 2p+1 by 2p+1.