从图像删除边界 [英] Removing Boundaries From Image

查看:101
本文介绍了从图像删除边界的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好
我的图片有一些文字,但有白色边距,我试图弄清楚如何从该图片中删除空白,因此图片只有文字
感谢您回答

Hello Everybody
I have an image that has some text but it has white margins, i am trying to figure out how to remove the gargins from that image so image has just the text
Thanks for answering

推荐答案

假定您已打开Windows Forms Project,并且在Form上设置了PictureBox.

1.对于此解决方案,您可以使用此图像[ ^ ],这是一个200x100px的.png文件(不透明),在黑色背景上显示白色文本,并且图像的所有侧面上都有一个15像素厚的内部边框".

2.将上面的图像设置为PictureBox的图像.

3.将PictureBox的SizeMode设置为CenterImage.

4.现在计算要显示的图像的实际部分:由于您希望在整个图像上裁剪15个像素:高度将减少30像素,宽度将减少30像素:因此将PictureBox的大小设置为170x70.

5.现在运行您的项目:观察白色边距是否被裁剪.

在其他情况下,实际上需要执行图形操作的地方可能需要更复杂的解决方案.

而且,当然,最简单的解决方案是在使用某个图像编辑器之前先对其进行裁剪……但是……如果您希望有时显示白色边距,而又将其隐藏,您仍然可以只需更改PictureBox的大小即可实现此目的.
Assume you have Windows Forms Project open, and PictureBox on the Form.

1. for this solution you might use this image[^], which is a 200x100px .png file (no transparency) on which white text appears on a black background, and there is an "interior border" 15 pixels thick on all sides of the image.

2. set the above image to be the PictureBox''s Image.

3. set the ''SizeMode of the PictureBox to ''CenterImage.

4. now calculate the actual part of the image you wish displayed : since you wish to crop 15 pixels around the whole image: it will be 30 pixels less in height, 30 pixels less in width: so set the PictureBox size to to 170x70.

5. now run your project: observe the white margin is cropped.

In other circumstances, more complex solutions may be required where you actually have to go through Graphics operations.

And, of course, the simplest solution of all is to crop the image in some simple image editor before you use it ... but ... if you want to show the white margin sometimes, but hide it other times, you can still achieve this by simply changing the size of the PictureBox.


这篇关于从图像删除边界的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆