我需要知道WPF与c#中两个图像之间的最高和最低像素

本文关键字:之间 图像 两个 像素 WPF | 更新日期: 2023-09-27 17:49:27

我将每个图像的像素存储在Col1和Col2中。我怎么知道哪个像素最高,然后放第三张图呢?

我对最高像素的定义是这个视频中的"穷市长"结果:https://www.youtube.com/watch?v=l1_WmoiKgPg

我还想知道如何对最低像素(视频中的"穷市长")进行设置。

   private void RadioButton_Checked(object sender, RoutedEventArgs e)
{
    WriteableBitmap imagen1bmp;
    WriteableBitmap imagen2bmp;
    WriteableBitmap imagencombinada;
    int x, y;
    imagen1bmp = (WriteableBitmap)laimagen1.Source;
    imagen2bmp = (WriteableBitmap)laimagen2.Source;

    for (y = 0; y < imagen1bmp.Height; y++)
    {
        for (x = 0; x < imagen1bmp.Width; x++)
        {
            //Get both colors in the pixel point
            Color col1 = LeePixel(imagen1bmp, x, y);
            Color col2 = LeePixel(imagen2bmp, x, y);

        }
        UpdateLayout();
    }
    UpdateLayout();
}

我需要知道WPF与c#中两个图像之间的最高和最低像素

所以首先要做的是根据你的定义了解什么是最高像素。从视频的结果来看,它似乎是原始RGB值的比较。所以基本上你选择最红的颜色然后如果它等于最绿的那么最蓝的。

要获得Color的原始值,需要调用方法toArgb。一个示例解决方案是:

Color col3; //the color for the output image for this pixel
if(col1.toArgb()>col2.toArgb())
    col3=col1;
else
   col3=col2;

对于最低的颜色,你只需要交换col1col2的影响。

至于将输出写入另一个图像,您似乎已经使用该LeePixel创建了一些自定义方法,因此我不确定如何以适合您的程序的方式做到这一点。