Home > Back-end >  About the skin color detection problem
About the skin color detection problem

Time:10-05

Shortly I am just learning to c + +, and many will not, also please teach a great god, I want to make a program that can detect color, then idioms started so
Byte * Line;
ImgDraw - & gt; Picture=img1 - & gt; Picture;
For (int y=0; Y & lt; ImgDraw - & gt; Picture - & gt; Bitmap - & gt; Height; + + y) {
The Line=(Byte *) imgDraw - & gt; Picture - & gt; Bitmap - & gt; ScanLine [y];
For (int x=0; X & lt; ImgDraw - & gt; Picture - & gt; Bitmap - & gt; Width; + + x) {
Unsigned short Red=Line [x * 3 + 2],
Green=Line [* 3 x + 1],
Blue=Line [x * 3];
You're not, so I got a skin color detection of idioms is below the
For (Y=0; Y & lt; Height; Y++)
{
Pointer=Scan0 + Y * Stride;
SkinP=SkinScan0 + Y * SkinStride;
For (X=0; X & lt; Width; X++)
{
Blue=* Pointer; Green=* (Pointer + 1); Red=* (Pointer + 2);
If (Red & gt; 95 & amp; & Green & gt; 40 & amp; & Blue & gt; 20 & amp; & Red & gt; Blue & amp; & Red & gt; Green & amp; & Math. Abs (Red, Green) & gt; 15)
{
If (Blue & gt;=Green)
{
Max=Blue;
Min=Green;
}
The else
{
Max=Green;
Min=Blue;
}
If (Red & gt; Max)
Max=Red;
Else if (Red & lt; Min)
Min=Red;
If (Max - Min & gt; 15) * SkinP=255;
}
Pointer +=3;
SkinP++;
}
How to use to find out the procedures to start using the program, anyone to complement the first application for me?

CodePudding user response:

The last time that you do and qoror similar, to help him solve the problem of the image difference comparison

CodePudding user response:

Can you help me to supplement the first a program again? Is to use the following program to the first, don't spend much time ah,

CodePudding user response:

Although I don't know you algorithm is a set of ideas, but I according to the principle of the three of you provide the code to write the most simplified code, a new effect and to what effect is the same, the original give you here, hope to help you, if you satisfied please knot!

 void __fastcall TForm1: : Button1Click (TObject * Sender) 
{
If (OpenPictureDialog1 - & gt; The Execute ()! {
=true)return;
}
Image1 - & gt; Picture - & gt; LoadFromFile (OpenPictureDialog1 - & gt; FileName);
For (int Y=0; Y & lt; Image1 - & gt; Height; Y++)
{
For (int X=0; X & lt; Image1 - & gt; Width; X++)
{
Int RGB=Image1 - & gt; Canvas - & gt; Pixels [X] [Y];
BYTE R=GetRValue (RGB);
BYTE G=GetGValue (RGB);
BYTE B=GetBValue (RGB);
If (R & gt; 95 & amp; & G & gt; 40 & amp; & B & gt; 20 & amp; & R & gt; B & amp; & R & gt; G & amp; & Abs (R - G) & gt; 15)
{
} else {
Image2 - & gt; Canvas - & gt; Pixels [X] [Y]=clRed;
}
}
}
}


Put a OpenPictureDialog, two Image and a button

CodePudding user response:

This code is loaded in BMP image idea

CodePudding user response:


CodePudding user response:

Code can be upstairs.
Void __fastcall TForm1: : Button1Click (TObject * Sender)
{
If (OpenPictureDialog1 - & gt; The Execute ()! {
=true)return;
}
Int the Max and Min.
Image1 - & gt; Picture - & gt; LoadFromFile (OpenPictureDialog1 - & gt; FileName);
//Image1 - & gt; Stretch=True;
For (int Y=0; Y & lt; Image1 - & gt; Height; Y++)
{
For (int X=0; X & lt; Image1 - & gt; Width; X++)
{
Int RGB=Image1 - & gt; Canvas - & gt; Pixels [X] [Y];
BYTE R=GetRValue (RGB);
BYTE G=GetGValue (RGB);
BYTE B=GetBValue (RGB);
If (R & gt; 95 & amp; & G & gt; 40 & amp; & B & gt; 20 & amp; & R & gt; B & amp; & R & gt; G & amp; & Abs (R - G) & gt; 15)
{
If (B & gt;=G)
{
Max=B;
Min=G;
}
The else
{
Max=G;
Min=B;
}
If (R & gt; Max)
Max=R;
Else if (R & lt; Min)
Min=R;

//face color retention
If (Max - Min & gt; 15) Image2 - & gt; Canvas - & gt; Pixels [X] [Y]=RGB;
//Image2 - & gt; Canvas - & gt; Pixels [X] [Y]=255;
} else {
//Image2 - & gt; Canvas - & gt; Pixels [X] [Y]=255;//=clRed
Image2 - & gt; Canvas - & gt; Pixels [X] [Y]=clWhite;
}
}
}
}

CodePudding user response:

In fact to be boundary detection?

CodePudding user response:

Actually don't need to be in my code

CodePudding user response:

The man obviously don't know where to go, will look for a knot posted
  • Related