Click here to Skip to main content
15,915,702 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralAuthentication Pin
Anthony988721-Jan-04 9:48
Anthony988721-Jan-04 9:48 
GeneralRe: Authentication Pin
Mike Dimmick22-Jan-04 1:38
Mike Dimmick22-Jan-04 1:38 
GeneralVersion info from resources Pin
ExtraLean21-Jan-04 9:32
ExtraLean21-Jan-04 9:32 
GeneralRe: Version info from resources Pin
Jörgen Sigvardsson21-Jan-04 10:01
Jörgen Sigvardsson21-Jan-04 10:01 
GeneralRe: Version info from resources Pin
Blake Miller21-Jan-04 10:04
Blake Miller21-Jan-04 10:04 
GeneralRe: Version info from resources Pin
John R. Shaw21-Jan-04 10:10
John R. Shaw21-Jan-04 10:10 
GeneralRe: Version info from resources Pin
ExtraLean21-Jan-04 10:26
ExtraLean21-Jan-04 10:26 
GeneralWritiing values of a variable to a file Pin
Obsidianick21-Jan-04 8:15
Obsidianick21-Jan-04 8:15 
GeneralRe: Writiing values of a variable to a file Pin
John R. Shaw21-Jan-04 9:36
John R. Shaw21-Jan-04 9:36 
GeneralRe: Writiing values of a variable to a file Pin
John M. Drescher21-Jan-04 9:41
John M. Drescher21-Jan-04 9:41 
GeneralSharing data within application Pin
David Crow21-Jan-04 8:02
David Crow21-Jan-04 8:02 
GeneralRe: Sharing data within application Pin
Joe Woodbury21-Jan-04 8:37
professionalJoe Woodbury21-Jan-04 8:37 
GeneralRe: Sharing data within application Pin
Blake Miller21-Jan-04 10:10
Blake Miller21-Jan-04 10:10 
GeneralExporting Device Context to File (GIF/JPG/PNG etc) Pin
Miszou21-Jan-04 6:34
Miszou21-Jan-04 6:34 
GeneralRe: Exporting Device Context to File (GIF/JPG/PNG etc) Pin
Nick Hodapp21-Jan-04 7:33
sitebuilderNick Hodapp21-Jan-04 7:33 
GeneralRe: Exporting Device Context to File (GIF/JPG/PNG etc) Pin
Miszou21-Jan-04 7:45
Miszou21-Jan-04 7:45 
GeneralRemove Pin
Anonymous21-Jan-04 6:20
Anonymous21-Jan-04 6:20 
GeneralRe: Remove Pin
David Crow21-Jan-04 6:55
David Crow21-Jan-04 6:55 
GeneralRe: Remove Pin
Anonymous21-Jan-04 7:28
Anonymous21-Jan-04 7:28 
GeneralRe: Remove Pin
David Crow21-Jan-04 7:56
David Crow21-Jan-04 7:56 
GeneralDrag and Drop from Outlook Pin
Steve Thresher21-Jan-04 5:47
Steve Thresher21-Jan-04 5:47 
GeneralShellOpen Pin
Gary Kirkham21-Jan-04 5:45
Gary Kirkham21-Jan-04 5:45 
GeneralRe: ShellOpen Pin
Antti Keskinen21-Jan-04 5:55
Antti Keskinen21-Jan-04 5:55 
GeneralRe: ShellOpen Pin
Gary Kirkham21-Jan-04 5:59
Gary Kirkham21-Jan-04 5:59 
QuestionHow to threshold an image? Pin
uus9921-Jan-04 5:41
uus9921-Jan-04 5:41 
Hi there, i'm doing image processing in VC++6. How can i perform thresholding (converting color to b&w) on an image, as fast as possible? I'm able to do using GetPixel & SetPixel but it is too slow. Anyway i can access the pixels directly??

Here is the code

//Image width=height=Big=360 px
int Big=360;

//Create a DC for buffering image
CDC MemDC,*pDC;
CBitmap MemBitmap;

// Get Current DC from dialog box,
pDC = myDlg->GetDC();

MemDC.CreateCompatibleDC(pDC);
//
MemBitmap.CreateCompatibleBitmap(pDC,Big,Big);
CBitmap *pOldBitmap = MemDC.SelectObject(&MemBitmap);


//------------custom hardware function that draws image from camera to DC-----------//
imgPlot ((GUIHNDL)MemDC.GetSafeHdc(), (void *)ImaqBuffer, 0, 0, Big, Big, 410, 10, plotFlag));
//-------------------------------------------

//My thresholding function, which is very slow!!!
//check every pixel, if it is bigger than threshold then turn it black
//and white otherwise
//**********
for(int i=0;i<360;i++)
for(int j=0;j<360;j++)
{

if(MemDC->GetPixel(i,j)<=RGB(64,128,255))
MemDC->SetPixel(i,j,RGB(0,0,0));
else
MemDC->SetPixel(i,j,RGB(255,255,255));
}

pDC->BitBlt(10,10,Big,Big,&MemDC,0,0,SRCCOPY); //See Note 3
MemDC.SelectObject(pOldBitmap);


//---------------------------


The code is too slow for real time. How can i do thresholding faster?

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.