Click here to Skip to main content
15,896,726 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi everyone,


I'm new in C I use visual studio 2010, I don't know how to display my output result, I've tried to use printf, but it failed, the result is not indicate the truth of calculation in my program.
Attached link is my project code.
it related with anisotropic filtering.
thanks in advance


http://www.sendspace.com/file/b2qs96[^]


[EDIT: Bring code from answer to question]


below a brief of my code :

main.cpp :

C++
#include <stdio.h>
#include <stdlib.h>
#include "anisodiff1D.h"
#include "anisodiff1D_initialize.h"
#include "anisodiff1D_terminate.h"
#include "rt_nonfinite.h"
#include "anisodiff1D.h"
#include "power.h"
#include "conv.h"
   
 int main(void)
 {
		real_T diff_sig_data[10];
		int32_T diff_sig_sizes[1];
        anisodiff1D_initialize();
		anisodiff1D(diff_sig_data,diff_sig_sizes);  
		anisodiff1D_terminate();
        system ("PAUSE");
        return 0;
 }


anisodiff1D.cpp :


C++
/* Include files */
#include "rt_nonfinite.h"
#include "anisodiff1D.h"
#include "power.h"
#include "conv.h"

void anisodiff1D(real_T diff_sig_data[11], int32_T diff_sig_sizes[1])
{
  static const real_T b_sig[11] = { 10,10,11,10,9,10,13,10,10,13,9 };
 

  int32_T t;
  int32_T nablaW_sizes;
  real_T nablaW_data[11];
  int32_T nablaE_sizes;
  real_T nablaE_data[11];
  real_T b_nablaW_data[11];
  real_T b_nablaE_data[11];
  int32_T tmp_sizes;
  real_T tmp_data[11];
  int iteration=5;
  int kappa=5.0;
 
  diff_sig_sizes[0] = 11;
  memcpy((void *)&diff_sig_data[0], (void *)&b_sig[0], 11U * sizeof(real_T));
  //real_T signal=diff_sig_data[nablaE_sizes];

  /*  Anisotropic diffusion. */
  for (t = 0; t < iteration; t++)  //loop as long as number iteration
  {
    conv(diff_sig_data, diff_sig_sizes, nablaW_data, *(int32_T (*)[1])&nablaW_sizes); //do the convolution to distinguish between edge end not
    b_conv(diff_sig_data, diff_sig_sizes, nablaE_data, *(int32_T (*)[1])&nablaE_sizes);
 
    /*  Diffusion function. */
 
    nablaW_sizes = 11;
    for (nablaE_sizes = 0; nablaE_sizes < 11; nablaE_sizes++) // the coefficient
	{
      b_nablaW_data[nablaE_sizes] = nablaW_data[nablaE_sizes] / kappa;
      b_nablaE_data[nablaE_sizes] = nablaE_data[nablaE_sizes] / kappa;
    }
 
	// function to get exp(-(nablaW/kappa).^2)
    power(b_nablaW_data, *(int32_T (*)[1])&nablaW_sizes, tmp_data, *(int32_T (*)[1])&tmp_sizes);
    nablaE_sizes = 11;
    power(b_nablaE_data, *(int32_T (*)[1])&nablaE_sizes, b_nablaW_data, *(int32_T (*)[1])&tmp_sizes);
 
	/*  Discrete PDE solution. */
	diff_sig_sizes[0] = 11;
    for (nablaE_sizes = 0; nablaE_sizes < 11; nablaE_sizes++) 
	{
      diff_sig_data[nablaE_sizes] = diff_sig_data[nablaE_sizes] + (1/3) * (((1.0 / (1.0 +tmp_data[nablaE_sizes]) * nablaW_data[nablaE_sizes] + 1.0 / (1.0 +b_nablaW_data[nablaE_sizes]) * nablaE_data[nablaE_sizes]))+(diff_sig_data[0]-diff_sig_data[nablaE_sizes]));
	
printf("%g\n",diff_sig_data);  
    }
		  
  }
 
}
Posted
Updated 17-Mar-12 2:21am
v2
Comments
Sergey Alexandrovich Kryukov 16-Mar-12 23:17pm    
It is not likely that someone will be interested in downloading of the whole RAR file in this indirect way from the unknown source; and relatively big volume of code is hardly adequate to this simple question.

You really should create a simple code sample comprehensively manifesting your problem and post it using "Improve question" above, formatted with "pre" tags. It can really be a few line of code, maybe even one...

--SA

The printf statement at the end of your function uses diff_sig_data as argument. This is an array and not a single value. Depending on what you want you should either output a single value, for example:

printf("%g\n", diff_sig_data[0]);


or the entire array by enclosing it in a loop

for (int i = 0; i < 11; ++i)
    printf("%g\n", diff_sig_data[i]);
 
Share this answer
 
Comments
linavaya 17-Mar-12 13:19pm    
thanks
if you are using Visual Studio you don't need that system("pause"); if you want to see your result in the console just press Ctr + F5 and the window wont disappear right away. If you press only F5 the window will flash with the result and you wont be able to see it (like other compilers )
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900