dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Aug 2012
    Posts
    5

    smoothing problem

    Dear Respected Friends.

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

    there is search and the output should be smooth. But the output is in stairstep.
    Can you please help me in resolving for smoothing.

    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 08:26 AM. Reason: Added code tags

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    19,144

    Re: smoothing problem

    AS it was told you in this thread you should use CODE tags around the code snippets.
    So, please, edit your code adding the absent code tags! Otherwise your code is very hard to read/understand.
    Victor Nijegorodov

  3. #3
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    6,221

    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??
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++17 Compiler: Microsoft VS2017 (15.7.2)

  4. #4
    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
    Attached Files Attached Files

  5. #5
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    6,221

    Re: smoothing problem

    That file is just the code from post #1.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++17 Compiler: Microsoft VS2017 (15.7.2)

  6. #6
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    19,144

    Re: smoothing problem

    Quote Originally Posted by khawar_geo View Post
    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?
    Victor Nijegorodov

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)


×
We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.