getpixels() 在 xp 和 vista 上获得正确的值,但在 Windows 7 上使用时略有偏差

发布于 2024-09-03 22:30:00 字数 854 浏览 3 评论 0原文

我有一个 C# 程序,可以在 xp 和 vista 上正常工作,但需要在 windows 7 上使用,我无法想出解决方案,看来 getpixels 在 windows 7 上无法正常工作

。获取 RGB 值之一,因为我正在处理 tiff 灰度图像。

 System.Drawing.Bitmap image;// this is in a separate class

 image = new Bitmap(destination);// this is in the constructor 

 Color t = image.GetPixel(j, i); // this is in a separate function
 int s = t.R 

当我打印 s 时,例如 image(0,0),它应该是 220,它将是 221

我正在图像上进行边缘检测,我必须逐像素地检查图像,我已经运行了完全相同的程序在 XP、Vista、windows7 和 windows 7 上得到不同的值。

它根本不允许我发布图像,而且只允许一个链接。

在此处输入图像描述

在此处输入图像描述

在此处输入图像描述

第一个图像是原始图像,第二个图像是正确的图像,也是我在 XP 和 Vista 上得到的图像,最终的图像是在 Windows 7 中运行相同程序时的图像。没有太大的明显差异,但这对我正在做的事情很重要。

I have a C# program that works correctly on xp and vista but it needs to be used on windows 7, I have not been able to come up with a solution, it appears that getpixels just doesn't work right on windows 7.

I am getting one of the RGB values because I am dealing with tiff grayscale images.

 System.Drawing.Bitmap image;// this is in a separate class

 image = new Bitmap(destination);// this is in the constructor 

 Color t = image.GetPixel(j, i); // this is in a separate function
 int s = t.R 

when I print s, for example, image(0,0), it is supposed to be 220, it will be 221

I am doing edge detection on an image and I have to go through the image pixel by pixel, I have run the exact same program on XP,Vista,windows7 and windows 7 got different values.

It wouldn't let me post images at all and only one link.

enter image description here

enter image description here

enter image description here

The first image is the original image, the second is the correct image, also the one I get with XP and Vista, the final image is the image when running the same program in Windows 7. There is not much of a visible difference but it matters for what I am doing.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

洋洋洒洒 2024-09-10 22:30:00

如果您指的是 Bitmap.GetPixel,该方法会返回 Color 结构。我假设当你说它“稍微偏离”时,返回颜色的 RGB 值与你期望的值略有不同。

这可能是因为您的 Windows 7 PC/图像的颜色深度与 XP 或 Vista 计算机不同,或者可能是 Windows 7 在 .Net 颜色的底层做了一些稍微不同的事情。这确实不重要,除非我怀疑您的代码正在寻找特定的颜色值。如果您发布更多详细信息,将会有所帮助。

If you mean Bitmap.GetPixel, that method returns a Color structure. I assume when you say it's "slightly off" that the RGB values of the returned color are slightly different than the value you're expecting.

This is probably due to your Windows 7 PC/image having a different color depth than your XP or Vista machines, or it may be that Windows 7 does something slightly different under the hood with .Net colors. This really shouldn't matter, except I suspect that your code is looking for a specific color value. It would help if you posted additional details.

°如果伤别离去 2024-09-10 22:30:00

根据文档,您确定您的程序确实正确吗?像这样的错误有时意味着您不小心依赖了未定义的行为。

Are you sure your program is really correct, according to the documentation? Bugs like this sometimes mean that you're accidentally relying on undefined behavior.

无声情话 2024-09-10 22:30:00

我刚刚结束使用 libtiff.net。

http://bitmiracle.com/libtiff/

I just ended up using libtiff.net.

http://bitmiracle.com/libtiff/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文