找到你要的答案

Q:resize image, get rid of 0-valued pixels Matlab

Q:调整图像大小,摆脱0值的像素的MATLAB

I've got an image with all pixel values set to 0 except for a small rectangular window region. What I'd like to do is resize the image to get rid of all the 0 valued pixels and just be left with the rectangular window region. What's the easiest way to do this in Matlab?

Thanks

我有一个图像,所有的像素值设置为0,除了一个小矩形窗口区域。我想做的是调整图像,以摆脱所有0值像素,只是留在矩形窗口区域。在MATLAB做这个最简单的方法是什么?

谢谢

answer1: 回答1:
[r, c] = find(img);

img_cropped = img(min(r):max(r), min(c):max(c))
[r, c] = find(img);

img_cropped = img(min(r):max(r), min(c):max(c))
matlab  matrix  resize