codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  calculating total black pixels in an image  shanthi85 at 02:50 on Wednesday, May 23, 2007
 

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]








CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums
//








Recent Forum Threads
•  Job @ EarlySail
•  Job @ EarlySail (perl)
•  Security - Code verify
•  IPC problem
•  Re: import contacts of msn/yahoo
•  Cookies and Threads C++
•  right justify a background in a table?
•  Help with Loop (C++/MFC)
•  Help with Loop (C++/MFC)


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2007