Michael Parra – Update 7

 

I have also been looking into HSV.  At this point I am unsure if I will use it but here are some extra things to look at in case we do include this. Estimated cutoff levels as our H
subspace skin boundaries,
(H < 25 ) AND (H > 230)

The equation to find H is :

M = Max(R,G,B)
m = min(R,G,B)
C = M – m

If (M == R)
h = (G −B)/C;
Else If (M == G)
h = 2 + (B − R)/C;
Else If ( M==B)
h = 4 + (R – G)/C;
Else
//C is Undefined and equations doesn’t really work.

H = h× 60

next is finally testing for 25 < H 75 && U130 && VU) ? 8’hff:{RGB565[15:13],RGB565[10:8],RGB565[4:3]};

assign R = {RGB565[15:11],3’b0};
assign G = {RGB565[10:5],2’b0};
assign B = {RGB565[4:0],3’b0};
assign abs = (R>G)? (R-G) : (G-R);

max max(
.A(R),
.B(G),
.C(B),
.Y(Max)
);
min min(
.A(R),
.B(G),
.C(B),
.Y(Min)
);

/*
assign R = RGB565[15:11];
assign G = RGB565[10:5];
assign B = RGB565[4:0];
// skyler pdf rgb test
assign dina = (10’d5<R && R<10'd17 && 10'd5<G && G<10'd17 &&
10'd5<B && B10’d1 && R-G>10’d1)
? 8’b00000011 : {RGB565[15:13],RGB565[10:8],RGB565[4:3]};
*/

//YCrCb equations and RGB with hair detection
assign dina = ((V>10)+21’d20) && (V>=((21’d353*U)>>10)+21’d76) && (V>=(21’d235-((21’d954*U)>>10)))
&& (V>10))) && (V>10))) && Y>8’d80
&& ((R>8’d95) && (G>8’d39) && (B>8’d23) && ((R+4)>G) && (R>B)
&& ((Max-Min)>8’d15))
|| ((R>8’d215) && (G>8’d207) && (B>8’d167) && (absB) && (R>B)))
? 8’b00000011 : ((R<105) && (G<81) && (B<73)
&& ((R-G)<17) && ((R-B)<33) && ((B-G)<17))
? 8'b00011100 : {R[7:5],G[7:5],B[7:6]};

//YCrCb Equations
/* assign dina = ((V>10)+21’d20) && (V>=((21’d353*U)>>10)+21’d76) && (V>=(21’d235-((21’d954*U)>>10)))
&& (V>10))) && (V>10))) && Y>8’d80)
? 8’b00000011 : {RGB565[15:13],RGB565[10:8],RGB565[4:3]};
*/

//SkinDetection RGB test (omit abs) working
// with Hair Detection
/*assign dina = ((R>8’d95) && (G>8’d39) && (B>8’d23) && ((R+8’d4)>G) && (R>B)
&& ((R>>2)>2)8’d215) && (G>8’d207) && (B>8’d167) && ((R-G)B) && (R>B))
? 8’b00000011 : ((R<105) && (G<81) && (B<73)
&& ((R-G)<17) && ((R-B)<33) && ((B-G)8’d95) && (G>8’d40) && (B>8’d20) && (R>G) && (R>B) && ((Max-Min)>8’d15)
// && U>75 && U130 && VU)
// ? 8’b00000011 : {R[7:5],G[7:5],B[7:6]};

//cb = u, cr = v;
//{R[7:5],G[7:5],B[7:6]}
//&& (U>80) && (U136) && (VU)) real yuv
/*
always @(*)begin
//Cb = (8’d128) – ((16’d152*R)>>10) – ((16’d298*G)>>10) + ((16’d450*B)>>10);
//Cr = (8’d128) + ((16’d450*R)>>10) – ((16’d377*G)>>10) – ((16’d73*B)>>10);
//Cb = (8’d128) – ((16’d152*{RGB565[15:11],3’b0})>>10) + ((16’d298*{RGB565[10:5],2’b0})>>10) + ((16’d450*{RGB565[4:0],3’b0})>>10);
//Cr = (8’d128) + ((16’d450*{RGB565[15:11],3’b0})>>10) – ((16’d337*{RGB565[10:5],2’b0})>>10) – ((16’d73*{RGB565[4:0],3’b0})>>10);
//if(Cr>150 && Cr100 && Cb135 && Cr77 && Cb=3 && RGB565[10:6]-RGB565[15:11]>10) – ((16’d296*G)>>10) + ((16’d446*B)>>10);
//V = (8’d128) + ((16’d630*R)>>10) – ((16’d527*G)>>10) + ((16’d103*B)>>10);
//////////////////////PB, Pr////SEMI////////////////////////////////////
//pb 128 – .115 – .385 – .5
//pr 128 + .5 – .454 – .046
//Cb = (8’d128) – ((16’d118*R)>>10) – ((16’d394*G)>>10) + (B>>1);
//Cr = (8’d128) + (R>>1) – ((16’d465*G)>>10) – ((16’d47*B)>>10);
////////////////////////////__close__///////////////////////////////////////
//cr= .439 -.368 -.071 +128
//cb= -.148 0.291 .439 +128
//cb = u, cr = v;
Y = ((8’d16) + ((16’d285*R)>>10) + ((16’d516*G)>>10) + ((16’d100*B)>>10));
U = ((8’d128) – ((16’d152*R)>>10) – ((16’d298*G)>>10) + ((16’d450*B)>>10));
V = ((8’d128) + ((16’d450*R)>>10) – ((16’d377*G)>>10) – ((16’d73*B)>>10));
/////////////////////messed_up///////////////////////////////////////////////
//Cr = 128 + 131/256 – 220/256 – 21/256
//Cb = 128 – 44/256 – 87/256 + 131/256
//Cr = (8’d128) + ((9’d131*R)>>8) – ((9’d110*G)>>8) – ((9’d21*B)>>8);
//Cb = (8’d128) – ((9’d44*R)>>8) – ((9’d87*G)>>8) + ((9’d131*B)>>1);
///////////////////////////////////////////////////////////////////////////////////
//cr = 128 + .5 – .419 – .081
//cb = 128 – .169 – .331 + .5
//Cr = (8’d128) + (R>>1) – ((9’d429*G)>>10) – ((9’d83*B)>>10);
//Cb = (8’d128) – ((9’d173*R)>>10) – ((9’d339*G)>>10) + (B>>1);
/////////////////////////__precise__///////////////////////////////////////////////
//Cr = (8’d128) + ((26’d524092*R)>>20) – ((26’d438862*G)>>20) – ((26’d85230*B)>>20);
//Cb = (8’d128) – ((26’d177141*R)>>20) – ((26’d347776*G)>>20) + ((26’d524907*B)>>20);
end

endmodule

///////////////////////////////////////////////////////////////////////
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 01:29:06 03/17/2016
// Design Name:
// Module Name: max
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 – File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module max(
input [7:0]A,
input [7:0]B,
input [7:0]C,
output reg [8:0]Y
);

always @(*)begin

if(A>B && A>C)
Y = A;
else if(B>A && B>C)
Y = B;
else
Y = C;

end

endmodule

`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 01:18:51 03/17/2016
// Design Name:
// Module Name: min
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 – File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module min(
input [7:0]A,
input [7:0]B,
input [7:0]C,
output reg [8:0]Y
);

always @(*)begin

if(A<B && A<C)
Y = A;
else if(B<A && B<C)
Y = B;
else
Y = C;

end

endmodule

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s