[英]Sample 8x8 patch from 512x512 image in Matlab
I would like to randomly sample an 8x8 patch from an image that is of size 512x512. 我想从512x512大小的图像中随机采样8x8补丁。 Is there a good (a quick and easy) way to do this in Matlab?
在Matlab中是否有很好的方法(快速简便)? All I want is an 8x8 matrix that was taken from the image.
我想要的只是从图像中获取的8x8矩阵。 And I each 8x8 block in the image to be equally likely.
我在图像中的每个8x8块都具有同等的可能性。
Say you have loaded the image using imread
into a variable called im
you can then do this: 假设您已使用
imread
将图像加载到名为im
的变量中,则可以执行以下操作:
r_X = randi(512-8);
r_Y = randi(512-8);
im_rand = im(r_X:r_X+8, r_Y:r_Y+8);
im_rand
will contain an 8x8 section of your image starting from a corner generated randomly. im_rand
将从随机生成的角开始包含图像的8x8区域。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.