CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com

1. Junior Member
Join Date
Aug 2012
Posts
5

## smoothing problem

Dear Respected Friends.

Good Morning. i hope you are fine.
I am making a code changing.

there is search and the output should be smooth. But the output is in stairstep.

Looking forward for help and.. thank you so much in advance.

Greetings

Below is my code.

Code:
```      int Imax = 10;
for ( int I=0; I<Imax; I++ ) {

for (int iy=0; iy<ny; iy++) {
for (int ix=0; ix<nx; ix++) {
float v1 = v[(iy*nx+ix)*nz];
int k1 =0;
int k0 =0;
int jstart = 0;
while (k1 < nz) {
int k;
for (k=k1; k<nz; k++) {
float v2 = v[(iy*nx+ix)*nz + k];

if ( 100. * fabs(v2 -v1) / v1 >= sharpeningThreshold_percentage/2. && jstart == 0 ) {
k0 = k;
jstart = 1;
}

if ( 100. * fabs(v2 -v1) / v1 >= sharpeningThreshold_percentage ) {
v1     = v2;
k1     = k;
jstart = 0;
for ( int kk=k0; kk<=k; kk++ )
v[(iy*nx+ix)*nz + kk] = v1;
k0 = k1;
break;
}
v[(iy*nx+ix)*nz + k] = v1;
}
if ( k >= nz-1 )
break;
}
}
}

if ( I < Imax-1 )
smooth(10, 1, v, nx, ny, nz);

} // sharpening -smoothing I-loop closed

} // if sharpeningThreshold_percentage  closed

}```
Last edited by 2kaud; February 10th, 2018 at 09:26 AM. Reason: Added code tags

2. ## Re: smoothing problem

AS it was told you in this thread you should use CODE tags around the code snippets.

3. ## Re: smoothing problem

[As Victor says in post #2, you need to use code tags when posting code. Go Advanced, select the formatted code and click '#']

the output should be smooth. But the output is in stairstep.
What output??

4. Junior Member
Join Date
Aug 2012
Posts
5

## Re: smoothing problem

Dear Respected colleague

Please find attached text file. I hope it may help.

Greetings and thank you

5. ## Re: smoothing problem

That file is just the code from post #1.

6. ## Re: smoothing problem

Originally Posted by khawar_geo
Dear Respected colleague

Please find attached text file. I hope it may help.

Greetings and thank you
Did you ever read the Announcement: Before you post....? Didn't you?

7. Junior Member
Join Date
Sep 2018
Posts
10

## Re: smoothing problem

I have through this code and face same problem. I have also found solution for this problem but couldn't get it.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•