调整图像大小 Matlab
我想调整图像大小,但在调整大小时应该保持高/宽比。我所做的是,首先检查哪一侧(宽度或高度)是长的。如果宽度很长,我会将宽度的大小设置为 150,并调整高度的大小,而不会影响图像的形状,反之亦然。我说的是用于边缘检测算法的调整大小的图像,并将输出二进制图像发送到需要恒定数量输入的神经网络。在这种情况下,图像的一侧(宽度或高度)为 150,另一侧小于 150(因图像而异)。但我想向另一侧(小于 150)添加黑色,直到其大小为 150。因此,我可以将 150*150 输入发送到神经网络。 问题是如何将黑色添加到另一侧(小于 150)直到其大小为 150?
提前致谢
I want to resize images, but it should keep the height/width ratio when doing the resizing. What I do is, first I check whether which side (width or height) is the long. If the width is long, I'll give 150 to the width's size and resize the height without affecting to the shape of the image and vise versa. I am talking this resized image for a edge detection algorithm and output binary image is sent to the neural network which requires constant number of inputs. In this case, one side of (width or height) the image is 150 and other side is less than 150(vary from image to image). But I want to add black color to the other side(less than 150) until its size is 150. So, I can sent 150*150 inputs to the neural network.
Question is How can I add black color to the other side(less than 150) until its size is 150?
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
http://www.mathworks.com/help/toolbox/images/ref /imresize.html
http://www.mathworks.com/help/toolbox/images/ref/padarray.html
http://www.mathworks.com/help/toolbox/images/ref/imresize.html
http://www.mathworks.com/help/toolbox/images/ref/padarray.html
创建一个零矩阵。计算左上角像素的位置。然后将图像复制到从左上角像素切片的矩阵中。
Creates an matrix of zeros. Calculate the position of the top-left pixel. Then copy your image to that matrix slicing from the top-left pixel.