Home > Net >  In c #, how to judge whether an image is red
In c #, how to judge whether an image is red

Time:09-17

To determine whether a picture in the red that should be how to write a rookie do you have a code can show me

CodePudding user response:

You use a Marshal. Copy the image RGB values to Copy an array, and then determine the value of R, if there is equal to 255 is red,

CodePudding user response:

As the upstairs said the value read from the picture, then circle whether these values being 255

CodePudding user response:

BMP. GetPixel (x, y) get color, determine whether to have r=255, g=0, b=0 point

CodePudding user response:

Guiyang
reference 3 floor old Ma Shanfu plugging waterproof engineering professional maintenance of swimming pool response:
BMP. GetPixel (x, y) get color, determine whether to have r=255, g=0, b=0 point

The building Lord asked less rigorous, 255 0 0 is red, but do you dare to say 254 0 0 not red? Combination down have hundreds or thousands of red, just we don't see to the naked eye,
Unless the original poster can persuade customers, 255 0 0 is red, 254 0 0 is not red,



CodePudding user response:

The desert plug-in ~ ~

CodePudding user response:

Helping to answer this

Color is a linear space, "red" is also a linear space

BMP. GetPixel (x, y) get color, mapped to the linear space, range can be filtered out

CodePudding user response:

Passage way of identifying
1. The binary operation, the three components dimension reduction to a linear space
2. The filtering recognition

https://blog.csdn.net/qq_44833786/article/details/90138769
The likelihood is vc code, opencv c # can also be used, however, means is consistent, the translation problems

CodePudding user response:

Access and modify the picture in the WPF color see WPF modify images

CodePudding user response:

 
Private void button1_Click (object sender, EventArgs e)
{
Bool TMP=GetRGB (Image. FromFile (" Amy polumbo ng ") as Bitmap, 237, 28, 36).//color RGB (237, 28, 36)
If (TMP) MessageBox. Show (" a ");
The else MessageBox. Show (" no ");
}

///& lt; Summary>
///do you have any specified color
///& lt;/summary>
///& lt; Param name="SRC" & gt; Image & lt;/param>
///& lt; Param name="tr" & gt; R value & lt;/param>
///& lt; Param name="tg" & gt; G value & lt;/param>
///& lt; Param name="TB" & gt; B value & lt;/param>
///& lt; Returns>
Public bool GetRGB (Bitmap SRC, int tr, tg int, int TB)
{
Bool has=false;

Int w=SRC. Width;
Int h=SRC. Height;
System. Drawing. Imaging. BitmapData srcData=https://bbs.csdn.net/topics/src.LockBits (new Rectangle (0, 0, w, h), System. Drawing. The Imaging. ImageLockMode. ReadOnly, System. Drawing. The Imaging. PixelFormat. Format32bppArgb);
The unsafe
{
Byte * pIn=(byte *) srcData Scan0. ToPointer ();
Byte * p;
Int stride=srcData. Stride;
Int r, g, b.
For (int y=0; Y & lt; h; Y++)
{
For (int x=0; X & lt; w; X++)
{
P=the pIn;
B=pIn [0];
G=the pIn [1];
R=pIn [2];
If (r==tr & amp; & G==tg & amp; & B==TB) {has=true; break; }
PIn +=4;
}
PIn +=srcData. Stride - w * 4;
}
}
The SRC. UnlockBits (srcData);
The return from the;
}
  •  Tags:  
  • C#