简体   繁体   English

Matlab中512x512图像中的示例8x8补丁

[英]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.

相关问题 如何在Java中读取图片并将其转换为字节数组?[以Lena.bmp 512x512为例] - How to read a image in java and turn it to byte array?[use Lena.bmp 512x512 as example] 对于AppStore(iTunes Connect)的512x512图像,Apple会像在手机上一样进行转角处理吗? - 512x512 image for AppStore (iTunes Connect), will Apple do corner rounding like they do on the phone? 如何在 javascript 中将 png 图像的像素的 512x512 高度图数组放大到 2017x2017 像素,以用作虚幻引擎 4 中的高度图? - How do you upscale a 512x512 to 2017x2017 heightmap array of pixels of a png image in javascript for use as a heightmap in Unreal Engine 4? Google Play虽然为512x512和32位RGBA,但不接受高分辨率图标 - Google Play isn't accepting high-res icon although it is 512x512 and 32-bit RGBA C# - 用白色字节填充图像字节以填充512 x 512 - C# - Padding image bytes with white bytes to fill 512 x 512 RuntimeError:给定输入大小:(512x1x1)。 计算出的 output 大小:(512x0x0)。 Output 尺寸太小 - RuntimeError: Given input size: (512x1x1). Calculated output size: (512x0x0). Output size is too small 我有图像(6000 * 6000)坚决。 是否一样:将其调整为(1000 * 1000),然后将其调整为(512 * 512),然后直接将其调整为(512 * 512)? - I have image (6000*6000) resolute. Is it the same :resizing it to (1000*1000) then resizing to (512*512) and resizing it to(512*512) directly? 如何将分割后的图像显示为8x8像素? - How to show a split images into 8x8 pixels? 图像的Matlab大小(x,y) - Matlab size of image (x,y) Keras从(None,None,None,512)重塑为(None,None,None,None,512)? - Keras reshape from (None,None,None,512) to (None,None,None,None,512)?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM