Matlab Question(About matrix sampling)

Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
1 reply · 5K views
miyakooo
Messages
1
Reaction score
0
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
 
Physics news on Phys.org
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.
 
Last edited: