我需要知道 C# 中 WPF 中两个图像之间的最高和最低像素是多少
I need to know what the highest and lowest pixel between two images in WPF with C#
我将每个图像的像素存储在 Col1 和 Col2 中。我怎么知道哪个是最高像素并放入第三张图像?
我对最高像素的定义是此视频中的 "por mayor" 结果:https://www.youtube.com/watch?v=l1_WmoiKgPg
我也想知道如何针对最低像素(视频中的"por mayor")进行处理。
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();
}
所以首先要做的是根据您的定义了解最高像素是多少。从视频的结果来看,它似乎是原始 RGB 值的比较。所以基本上你 select 最红的颜色然后如果它等于最绿然后最蓝。
要获取 Color
的原始值,您需要调用方法 toArgb
。一个示例解决方案是:
Color col3; //the color for the output image for this pixel
if(col1.toArgb()>col2.toArgb())
col3=col1;
else
col3=col2;
最低的颜色你只需要在做作中交换col1
和col2
。
至于将输出写入另一个图像,您似乎已经用那个 LeePixel
创建了一些自定义方法,所以我不确定如何以适合您的程序的方式进行。
我将每个图像的像素存储在 Col1 和 Col2 中。我怎么知道哪个是最高像素并放入第三张图像?
我对最高像素的定义是此视频中的 "por mayor" 结果:https://www.youtube.com/watch?v=l1_WmoiKgPg
我也想知道如何针对最低像素(视频中的"por mayor")进行处理。
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();
}
所以首先要做的是根据您的定义了解最高像素是多少。从视频的结果来看,它似乎是原始 RGB 值的比较。所以基本上你 select 最红的颜色然后如果它等于最绿然后最蓝。
要获取 Color
的原始值,您需要调用方法 toArgb
。一个示例解决方案是:
Color col3; //the color for the output image for this pixel
if(col1.toArgb()>col2.toArgb())
col3=col1;
else
col3=col2;
最低的颜色你只需要在做作中交换col1
和col2
。
至于将输出写入另一个图像,您似乎已经用那个 LeePixel
创建了一些自定义方法,所以我不确定如何以适合您的程序的方式进行。