Click here to Skip to main content
15,903,012 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: How to get most significant digit ? Pin
Prakash Nadar23-Mar-04 23:19
Prakash Nadar23-Mar-04 23:19 
GeneralTab Order and access keys Pin
Jeremy Pullicino23-Mar-04 22:15
Jeremy Pullicino23-Mar-04 22:15 
GeneralRe: Tab Order and access keys Pin
Steve S24-Mar-04 6:36
Steve S24-Mar-04 6:36 
GeneralPercentage... Pin
JeabJB23-Mar-04 22:09
JeabJB23-Mar-04 22:09 
GeneralRe: Percentage... Pin
Maximilien24-Mar-04 0:55
Maximilien24-Mar-04 0:55 
GeneralCFormView in CSplitterWnd Pin
soggie23-Mar-04 22:07
soggie23-Mar-04 22:07 
GeneralRe: CFormView in CSplitterWnd Pin
Mike Dimmick24-Mar-04 2:28
Mike Dimmick24-Mar-04 2:28 
GeneralRecursive function to non recursive fcn Pin
jammin PPP23-Mar-04 21:49
jammin PPP23-Mar-04 21:49 
hey all below is a bit of code that i am working on at the moment - it a region growing function.... initially i had it written as a recursive function, but i was running into problems related to running out of stack space. so i need to rewrite it as a non recursive function, but i am stumped as to how? Can anyone provide some hints or tips??

Recursive version of the function(s) follow
// Code is called by
void CAviView::RegionGrow(CPoint pt_in) // Issue when coming out of region growing process -
{
MessageBox("Region Growing function called", "Region Growing", MB_ICONERROR | MB_OK);
CPoint realxy;
int threshold; // Amount of difference allowed in order to pass test test-conducted to determine if similar enough for same region
BYTE r,g,b;

threshold = 50; // Use 10 as initial value for threshold on region growing
realxy.x = int(pt_in.y / m_smallestscalefactor); // SURE now, they are correct.
realxy.y = int(pt_in.x / m_smallestscalefactor);

m_bmp.GetRGB(realxy.x, realxy.y, r,g,b);
m_bmp.SetRGB(realxy.x, realxy.y, RGB(255,g,b)); // possibly get the original values for B and G

Check8Neighbours2(realxy, threshold);
//m_isRegionGrowing = false;
Invalidate();
}

//Actual recursive implementation of the function.
bool CAviView::Check8Neighbours2(CPoint pt_in, int thresh_in)
{
bool match = false;
int startbval = m_bmp.Get256Level(pt_in.x, pt_in.y); // initial brightness value of selected start pixel
BYTE r,g,b;
int threshold = thresh_in;
int testbval;
// Should this RegionMap be a local or a global variable??? - how does the recursive nature of this functoin handle it?
m_RegionMap = C256GreyDIBitmap(m_bmp.Rows(), m_bmp.Cols(), 1); // This bitmap should hold a map of which pixels lie in which regions regions are given by the 256grey level allowing for up to 256 different regions in any given image
m_RegionMap.Set256Level(pt_in.x, pt_in.y, 1); // 1 = In selected region, 2 /200 = NOT in selected region
CPoint new_pt;

for (int i = -1; i < 2; i++){
for(int j = -1; j < 2; j++){
int m=pt_in.x+i;
int n=pt_in.y+j;
int test2 = m_RegionMap.Get256LevelSafe(m,n);
if ( test2 == 1 || test2 == 200){
}
else
{

testbval = m_bmp.Get256LevelSafe(m, n);
if (abs(testbval - startbval) < threshold){
TRACE("\n trace test2");
m_bmp.GetRGB(m, n, r,g,b);
m_bmp.SetRGB(m, n, RGB(255,g,b));
m_RegionMap.Set256Level(m,n,1);
new_pt.x = m;
new_pt.y = n;

if (( (1 < m) && (m < (m_bmp.Cols()-1) ) && ( (1< n) && (n < (m_bmp.Rows()-1))))){
TRACE("\nFound 1 positive match");
Check8Neighbours (new_pt,threshold); // ?? Problem lies in the recursive calling of this function?????
}
}

else{
m_RegionMap.Set256Level(m,n,200); // USE 2 or 200 to designate a different region area. ie. pixel has been tested and thrown away as not in region1
}
match = true;
}

}
}
// Use bitmap display for visual check of R egionMap
CBitmapDisplayDlg test3(m_RegionMap, "Testing");
test3.DoModal();
return match;
}
QuestionHow to download file from internet partially ? Pin
vgrigor23-Mar-04 21:30
vgrigor23-Mar-04 21:30 
AnswerRe: How to download file from internet partially ? Pin
Prakash Nadar23-Mar-04 21:40
Prakash Nadar23-Mar-04 21:40 
GeneralRe: How to download file from internet partially ? Pin
vgrigor23-Mar-04 21:44
vgrigor23-Mar-04 21:44 
GeneralRe: How to download file from internet partially ? Pin
Prakash Nadar23-Mar-04 21:49
Prakash Nadar23-Mar-04 21:49 
GeneralRe: How to download file from internet partially ? Pin
vgrigor23-Mar-04 21:51
vgrigor23-Mar-04 21:51 
GeneralRe: How to download file from internet partially ? Pin
Prakash Nadar23-Mar-04 21:59
Prakash Nadar23-Mar-04 21:59 
GeneralRe: How to download file from internet partially ? Pin
vgrigor23-Mar-04 22:02
vgrigor23-Mar-04 22:02 
GeneralRe: How to download file from internet partially ? Pin
Prakash Nadar23-Mar-04 22:05
Prakash Nadar23-Mar-04 22:05 
AnswerRe: How to download file from internet partially ? Pin
Mike Dimmick24-Mar-04 2:37
Mike Dimmick24-Mar-04 2:37 
GeneralRe: How to download file from internet partially ? Pin
vgrigor24-Mar-04 3:16
vgrigor24-Mar-04 3:16 
GeneralRe: How to download file from internet partially ? Pin
Anonymous24-Mar-04 5:21
Anonymous24-Mar-04 5:21 
QuestionHow to hook Internet Explorer Pin
Anonymous23-Mar-04 21:25
Anonymous23-Mar-04 21:25 
AnswerRe: How to hook Internet Explorer Pin
David Crow24-Mar-04 2:47
David Crow24-Mar-04 2:47 
GeneralRe: How to hook Internet Explorer Pin
Anonymous24-Mar-04 4:42
Anonymous24-Mar-04 4:42 
GeneralRe: How to hook Internet Explorer Pin
David Crow24-Mar-04 5:11
David Crow24-Mar-04 5:11 
GeneralRe: How to hook Internet Explorer Pin
Anonymous25-Mar-04 18:15
Anonymous25-Mar-04 18:15 
GeneralApplication Hooking Pin
Anonymous23-Mar-04 21:15
Anonymous23-Mar-04 21:15 

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.