计算图像的像素长度
请问1像素的长度(厘米)有哪些计算方法?我的图像是 640x480。我想比较图像上不同位置的 2 个像素并找出距离差异。因此我需要找出像素的长度(以厘米为单位)。 谢谢。
May I know what are the ways to calculate the length of 1 pixel in centimeters? The images that I have are 640x480. I would like to compare 2 pixels at different places on the image and find the difference in distance. Thus I would need to find out what's the length of the pixel in centimeters.
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
像素是相对测量单位,它没有绝对大小。
编辑。关于您的编辑:同样,您只能以像素为单位计算图像中两个像素之间的距离,而不能以厘米为单位。举一个简单的例子,想想视频投影仪:如果你将 3×3px 的图像投影到墙上,最左边和最右边像素之间的距离可能是从几毫米到几米。如果您将投影仪移近或远离墙壁,像素大小就会发生变化,并且您之前计算的任何距离都会变得错误。
计算机显示器和其他设备也是如此(正如 Johannes Rössel 在他的回答中所解释的那样)。其中,以厘米为单位的像素大小取决于屏幕的物理分辨率、图形界面的分辨率以及显示图像的缩放系数等因素。
根据定义,像素没有固定的物理尺寸。它只是图片的最小可寻址单元,无论大小。
A pixel is a relative unit of measure, it does not have an absolute size.
Edit. With regard to your edit: again, you can only calculate the distance between two pixels in an image in pixels, not in centimeters. As a simple example, think video projectors: if you project, say, a 3×3px image onto a wall, the distance between the leftmost and the rightmost pixels could be anything from a few millimeters to several meters. If you moved the projector closer to the wall or farther away from it, the pixel size would change, and whatever distance you had calculated earlier would become wrong.
Same goes for computer monitors and other devices (as Johannes Rössel has explained in his answer). There, the pixel size in centimeters depends on factors such as the physical resolution of the screen, the resolution of the graphical interface, and the zooming factor at which the image is displayed.
A pixel does not have a fixed physical size, by definition. It is simply the smallest addressable unit of picture, however large or small.
这完全取决于屏幕分辨率和屏幕尺寸:
This is fully dependent on the screen resolution and screen size:
实际上,答案取决于您的现实世界单位的具体位置。
它可归结为 dpi(每英寸点数),即沿 2.54 厘米长度的图像像素数。这是图像或目标设备(打印机、屏幕等)的分辨率。
图像文件通常嵌入有一个分辨率,用于指定其实际大小。它不会改变它们的像素尺寸,它只是说明打印后它们有多大,或者显示器上的“100%”视图有多大。
然后是屏幕的分辨率,正如其他人提到的,以及图形界面使用的指定分辨率(通常为 96 dpi,有时为 120),然后就是程序是否真正遵循该设置的问题......
Actually, the answer depends on where exactly your real-world units are.
It comes down to dpi (dots per inch) which is the number of image pixels along a length of 2.54 cm. That's the resolution of an image or a target device (printer, screen, &c.).
Image files usually have a resolution embedded within them which specifies their real-world size. It doesn't alter their pixel dimensions, it just says how large they are if printed or how large a “100 %” view on a display would be.
Then there is the resolution of your screen, as others have mentioned, as well as the specified resolution your graphical interface uses (usually 96 dpi, sometimes 120)—and then it's all a matter of whether programs actually honor that setting ...
操作系统将假定一定的 dpi(在 Windows 上通常为 96 dpi),但是屏幕的实际 dpi 将取决于显示器的物理尺寸和分辨率,
例如 15 英寸显示器应具有 12 英寸宽度,因此取决于您将获得的水平分辨率不同的水平 dpi,假设屏幕宽度为 1152 像素,您将真正获得 96 dpi
The OS will assume some dpi (usually 96 dpi on windows) however the screens real dpi will depend on the physical size of the display and the resolution
e.g a 15" monitor should have a 12" width so depending on the horizontal resolution you will get a different horizontal dpi, assuming a 1152 pixel screen width you will genuinely get 96 dpi