Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Matlab Question(About matrix sampling)

  1. Nov 22, 2009 #1
    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
     
  2. jcsd
  3. Nov 24, 2009 #2
    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: Nov 24, 2009
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Matlab Question(About matrix sampling)
  1. MATLab matrix question (Replies: 1)

Loading...