像素颜色C# [英] Pixel Color C#

查看:66
本文介绍了像素颜色C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一张包含一些多项选择题的扫描图片。所以,首先我如何计算特定圆圈内大多数像素的平均颜色(我已经知道如何获得一个像素的颜色)

Hi, I have a scanned image which contains some multiple-choice questions. So, first of all how could I calculate the average color for most pixels inside a specific circle (I already know how to get the color of one individual pixel)

其次,我是如何达到的一个const位置,起初我想到达像素,但是如果我的扫描图像有150dpi,并且用300dpi扫描相同的图像呢?

Second, how got I reach an const location, at first I thought of reaching pixels but what if my scanned image has 150dpi, and the same image was scanned with 300dpi?

推荐答案

假设您知道圆圈的大小和位置,平均很容易。 在300dpi时,1/4"圆圈的直径为75像素。 最简单的方法就是将周围正方形中所有像素的R,G和B分量相加,
除以75x75。 包含填充圆圈的正方形将比具有空圆圈的正方形暗得多。 只有两个嵌套的for循环,对于y = 0到74,对于x = 0到74,并添加'em up。

Averaging is easy, assuming you know the size and location of the circle.  At 300 dpi, a 1/4" circle will have a diameter of 75 pixels.  The easy thing would be just to add up the R, G, and B components of all pixels in the surrounding square, and divide by 75x75.  A square containing a filled in circle will be much darker than a square with an empty circle.  Just two nested for loops, for y = 0 to 74, for x = 0 to 74, and add 'em up.

你应该能够从图像头获取DPI  如果没有,那么您可以从图像大小中获取它。  300 DPI的8.5x11扫描纸张为2550 x 3300. 在150 DPI时它是1275 x 1650。

You ought to be able to get the DPI from the image header.  If not, then you can get it from the image size.  An 8.5x11 scanned sheet at 300 DPI is 2550 x 3300.  At 150 DPI it is 1275 x 1650.


这篇关于像素颜色C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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