|
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;
}
|
|
|
|
|
I need to download end of file only,
of know size.
How to do it?
I searched WINHTTP and Wininet libraries reference,
and not find such a method,
but it is widely used in download managers.
Can someone point me a library and methods that can do this ?
(library can be else than two cited here, but free).
thanks.
|
|
|
|
|
You need partial downloading concept.. Read the RFC on HTTP 1/1 how to read partial file from the internet.
MSN Messenger.
prakashnadar@msn.com
Tip of the day of visual C++ IDE.
"We use it before you do! Visual C++ was developed using Visual C++"
|
|
|
|
|
I need people who read and understand,
but not sender far.
There is people who knows?
|
|
|
|
|
What kind of information are you looking at the end of the file? and how much end of the file ? after end of the file there is void.
MSN Messenger.
prakashnadar@msn.com
Tip of the day of visual C++ IDE.
"We use it before you do! Visual C++ was developed using Visual C++"
|
|
|
|
|
No need to understnd this.
need to do.
|
|
|
|
|
Then Just do it.
MSN Messenger.
prakashnadar@msn.com
Tip of the day of visual C++ IDE.
"We use it before you do! Visual C++ was developed using Visual C++"
|
|
|
|
|
I asked it at people there.
You only speak much.
Please better not making spam here,
I do not want to loose time to it, (as with your responces).
Dowes someone know how to use HTTP headers?
|
|
|
|
|
Ok you are the boss with the question.
MSN Messenger.
prakashnadar@msn.com
Tip of the day of visual C++ IDE.
"We use it before you do! Visual C++ was developed using Visual C++"
|
|
|
|
|
If you're using FTP, use FtpCommand to send a REST (RESTart) command before calling FtpOpenFile and InternetReadFile to get the data. See RFC 959[^].
If you're using HTTP, you can set the Range header to indicate which part of the document you want to retrieve. See RFC 2616 (HTTP/1.1)[^]. Send headers with HttpSendRequest .
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Can you write C++ method,
even in concide form, to show using that header for http ?
This is my primary purpose for ask.
|
|
|
|
|
vgrigor wrote:
Can you write C++ method
yeah i will write it for you but my rate is $300 / hour and paid in advance.
|
|
|
|
|
How can a VC program detect the site address visited from the IE ?
|
|
|
|
|
I think what you are asking about is a Browser Helper Object (BHO).
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Actually we want a practial example.(i.e. code)
|
|
|
|
|
You can search here at CP, MSDN, and Google. You'll find tons of examples.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Can my program be notified if the address bar in IE is changed ? how?
|
|
|
|
|
How can I detect a Windows application opened/closed from my VC program?
|
|
|
|
|
Look into SetWindowsHookEx using the WH_SHELL hook.
|
|
|
|
|
Could you please explain it with a small example?
I want to continiously monitor the applications opening in Windows.
Thanks
|
|
|
|
|
Yes, I will try to wrie up an article for it.
I am REALLY busy at the moment, so you will have to be patient.
Also, go to the article request message board and post a request there as well.
Someone else might get to it before I do.
And you run and you run to catch up with the sun but it's sinking, coming around to meet you again...
|
|
|
|
|
I'm dumb founded at this.
I can't for the life of me figure out how to find out how much memory is being allocated for a vector.
I mean I want the actual number of bytes it is using in memory.
If anyone can help me with this, I'd be very thankful.
|
|
|
|
|
Anonymous wrote:
I'm dumb founded at this.
I can't for the life of me figure out how to find out how much memory is being allocated for a vector.
I mean I want the actual number of bytes it is using in memory.
If anyone can help me with this, I'd be very thankful.
sizeof() ?
|
|
|
|
|
Anonymous wrote:
I'm dumb founded at this.
I can't for the life of me figure out how to find out how much memory is being allocated for a vector.
I mean I want the actual number of bytes it is using in memory.
If anyone can help me with this, I'd be very thankful.
sizeof(data)*sizeof(vector) ?
|
|
|
|
|
int nSize = sizeof (vMyVector) + sizeof (vMyVector [0]) * vMyVector .capacity;
Please remember that this is TOTALLY implemtation specific and runs a very good chance of being wrong.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|