|
this is the algorithm for calculating black pixels and then finding them recursively in the image...how do i change it into a VB program?
[CODE]//tests if a pixel is black
/*==============================================================*/
bool IsBlack(int row, int col, LPVOID BaseAddress)
{
//a pixel’s RGB val is returned
COLORREF* pPixel = ((COLORREF*) BaseAddress) + row * 640;
COLORREF curPixel = pPixel[col];
BYTE red = GetRValue(curPixel);
BYTE blue = GetBValue(curPixel);
BYTE green = GetGValue(curPixel);
int black = 150; //RGB value to determine if Pixel is Black
//returns black if RGB vals < highest acceptable black val
if (red < black && blue < black && green < black)
{return true;}
else
{return false;}
}[/CODE]
[CODE]MapPattern(row, col)
{
/*Checks the above pixel if it is black and unmarked, if it is then the pixel is flagged into the Points structure and the MapPattern function is run with the above pixel as the parameter*/
if (Field[row–1][col] = black AND Points[row–1][col] != 1)
{
Points[row – 1][col] = 1
MapPattern(row – 1, col)
}
/* The same process checks the pixel beneath the input
location (note the statement checks if the pixel is pre-
existing before reentering the recursion*/
if (Field[row+1][col] = black AND Points[row+1][col] != 1)
{
Points[row + 1][col] = 1
MapPattern(row + 1, col)
}
/*Checking the pixel left*/
if (Field[row][col–1] = black AND Points[row][col–1] != 1)
{
Points[row][col – 1] = 1
MapPattern(row, col – 1)
}
/*Checking the right pixel*/
if (Field[row][col+1] = black AND Points[row][col+1] != 1)
{
Points[row][col + 1] = 1
MapPattern(row, col + 1)
}
}[/CODE]
|
|
|
|
|
|
|
// |