Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hi everyone, Below is part of my s

Status
Not open for further replies.

kan13

Technical User
Mar 4, 2003
6
MU
Hi everyone,
Below is part of my source code which consists of reading the intensities of pixels along 25 vertical intervals in a pgm picture format. The problem is that I'm having only the first value of H at the first interval, which means the first "for loop" is not incrementing.I want to have the values of H at each interval.Please help me.
Thanks.

void CKevinView::OnIndex()
{
// TODO: Add your command handler code here
int first;
int count;
int H;
int interval=NewImage.width/25;


for (int j = interval; j <= NewImage.width; (j+=interval)++)
{
first=0;
count=0;

for ( int i=0; i<NewImage.height; i++)

{
if (NewImage.matrix[j].real > 50 )

first++;


if (NewImage.matrix[j].real > 230)

count++;


}



}
H=((first-count)/count)*100;
m_show.m_h = count;
m_show.DoModal();

}



 
(j+=interval)++ looks wierd.

Why not just do a
j+=interval
---------------
Normally I'd expect
for (int j = 0; j < NewImage.width; j+=interval)
rather than
for (int j = interval; j <= NewImage.width; (j+=interval)++)
but of course it depends on your logic...
---------------
Anyway if it doesn't loop as expected:
* Check that NewImage.width > interval. It wont be if NewImage.width <= 25
* Set a breakpoint to find why it fails
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top