Matlab Question(About matrix sampling)

Click For Summary
SUMMARY

The discussion centers on sampling random regions from an image using MATLAB. The user, Miyakooo, seeks assistance in generating a matrix-shaped region centered around a random point in the image. A solution is provided, which involves using random index values (i, j) to create a submatrix. The specific MATLAB code snippet shared is: submatrix = image((i-p):(i+p), (j-p):(j+p)), which effectively extracts a submatrix of size 2p+1 by 2p+1 centered at the specified indices.

PREREQUISITES
  • Basic knowledge of MATLAB programming
  • Understanding of image representation as matrices
  • Familiarity with matrix indexing in MATLAB
  • Concept of random number generation in programming
NEXT STEPS
  • Explore MATLAB's image processing toolbox for advanced image manipulation techniques
  • Learn about random sampling methods in MATLAB for statistical analysis
  • Investigate MATLAB functions for visualizing submatrices
  • Study the implications of pixel sampling on image quality and data analysis
USEFUL FOR

This discussion is beneficial for students and professionals in image processing, MATLAB programmers, and anyone interested in random sampling techniques for data analysis in images.

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:

Similar threads

  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 9 ·
Replies
9
Views
5K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 9 ·
Replies
9
Views
4K