在我的图像类中,我希望在将像素传递给Image之后更改它们,并且它们应该仍然会更改图片。
int main(int argc, char* argv[]){
Image theImage(4, 8);//width/height
Pixel aPixel(2,1);
Pixel* p = &aPixel;
theImage.setPixel(p);
aPixel.setBlue(100);//change the blue (RGB) value of the pixel, but Pixel color doesnt change
theImage.sa
所以我有一个二维数组,表示一个坐标平面,一个图像。在那张图片上,我正在寻找“红色”像素,并根据我的相机找到的所有红色像素,找到(希望)红色LED目标的位置。目前,我只是在所有红色像素的质心上拍打我的十字线:
// pseudo-code
for(cycle_through_pixels)
{
if( is_red(pixel[x][y]) )
{
vals++; // total number of red pixels
cx+=x; // sum the x's
cy+=y; // sum the y's
}
}
c
我想绘制网格,如下图所示。
我知道一个技巧,通过绘制6条垂直线和水平线而不是6 x 6个小矩形来绘制它。
但是,如果我想要更小的缩放(用于查看图片的缩放),行很多。例如,假设我的视图窗口大小为800 x 600,正在查看一张大小为400 x 300的图片(因此放大为2)。将有400 x 300个大小为2 x 2的矩形(每个矩形代表一个像素)。
如果我画每个单元格(在一个循环中,比方说400 x 300次),它是非常慢的(当我移动窗口...)。使用这个技巧可以解决这个问题。
我仍然很好奇在winapi中有没有更好的方法来完成这个任务,GDI(+)。例如,像DrawGrid(HDC hdc,
我有里面有多边形的图像。有黑线穿过这些多边形。我需要一个方法来删除这些黑线与最小的改变多边形。到目前为止,我已经尝试过:
Step 1) parse the image from the top left corner to the bottom right corner(line by line).
Step 2) Loop through each pixel of a line/row.
Step 3) If you encounter a non-black pixel, put the color value of it in
a variable (lets ca
第1部分:编写函数def setPixelToBlack(像素),将每个像素的颜色更改为黑色。 图片:编写函数def setPictureToBlack(图片),使图片变黑。该函数必须调用第1部分中的setPixelToBlack。 我已经设置了我的setPixelToBlack(像素)代码,但是不知道如何在setPictureToBlack(图片)函数中使用它! def setPixelToBlack(pixel):
for p in getPixels(pixel):
value = getRed(p)
setRed(p, value * 0)
value = ge