EDN Admin
Well-known member
Hi everyone,<br/>
<br/>
<br/>
<br/>
<br/>
Im new in C I use visual studio 2010, I dont know how to display my output result, Ive tried to use printf, but it failed, the result is not indicate the truth of calculation in my program.<br/>
Attached link is my project code (complete file). http://www.sendspace.com/file/b2qs96" id="x_x_yui_3_2_0_7_1331945337614413 " target="_blank" style="color:#3a65bb; outline-width:0px; outline-style:initial; outline-color:initial; font-family:Arial,Helvetica,sans-serif; line-height:normal <span id="x_x_lw_1331953010_3 http://www.sendspace.com/file/b2qs96 <br/>
it related with anisotropic filtering. and below are some part of my code :<br/>
thanks in advance<br/>
<br/>
<span style="font-family:Verdana,Arial,sans-serif; line-height:normal main.cpp :<br style="font-family:Verdana,Arial,sans-serif; line-height:normal
<span style="font-family:Verdana,Arial,sans-serif; line-height:normal <br style="font-family:Verdana,Arial,sans-serif; line-height:normal
<span style="font-family:Verdana,Arial,sans-serif; line-height:normal #include <stdio.h style="font-family:Verdana, Arial, sans-serif;line-height:normal; <br/>
#include <stdlib.h><br/>
#include "anisodiff1D.h"<br/>
#include "anisodiff1D_initialize.h"<br/>
#include "anisodiff1D_terminate.h"<br/>
#include "rt_nonfinite.h"<br/>
#include "anisodiff1D.h"<br/>
#include "power.h"<br/>
#include "conv.h"<br/>
<br/>
int main(void)<br/>
{<br/>
real_T diff_sig_data[10];<br/>
int32_T diff_sig_sizes[1];<br/>
anisodiff1D_initialize();<br/>
anisodiff1D(diff_sig_data,diff_sig_sizes); <br/>
anisodiff1D_terminate();<br/>
system ("PAUSE");<br/>
return 0;<br/>
}<br/>
<br/>
<br/>
<br/>
anisodiff1D.cpp :<br/>
<br/>
/* Include files */<br/>
#include "rt_nonfinite.h"<br/>
#include "anisodiff1D.h"<br/>
#include "power.h"<br/>
#include "conv.h"<br/>
<br/>
void anisodiff1D(real_T diff_sig_data[11], int32_T diff_sig_sizes[1])<br/>
{<br/>
static const real_T b_sig[11] = { 10,10,11,10,9,10,13,10,10,13,9 };<br/>
<br/>
<br/>
int32_T t;<br/>
int32_T nablaW_sizes;<br/>
real_T nablaW_data[11];<br/>
int32_T nablaE_sizes;<br/>
real_T nablaE_data[11];<br/>
real_T b_nablaW_data[11];<br/>
real_T b_nablaE_data[11];<br/>
int32_T tmp_sizes;<br/>
real_T tmp_data[11];<br/>
int iteration=5;<br/>
int kappa=5.0;<br/>
<br/>
diff_sig_sizes[0] = 11;<br/>
memcpy((void *)&diff_sig_data[0], (void *)&b_sig[0], 11U * sizeof(real_T));<br/>
//real_T signal=diff_sig_data[nablaE_sizes];<br/>
<br/>
/* Anisotropic diffusion. */<br/>
for (t = 0; t < iteration; t++) //loop as long as number iteration<br/>
{<br/>
conv(diff_sig_data, diff_sig_sizes, nablaW_data, *(int32_T (*)[1])&nablaW_sizes); //do the convolution to distinguish between edge end not<br/>
b_conv(diff_sig_data, diff_sig_sizes, nablaE_data, *(int32_T (*)[1])&nablaE_sizes);<br/>
<br/>
/* Diffusion function. */<br/>
<br/>
nablaW_sizes = 11;<br/>
for (nablaE_sizes = 0; nablaE_sizes < 11; nablaE_sizes++) // the coefficient<br/>
{<br/>
b_nablaW_data[nablaE_sizes] = nablaW_data[nablaE_sizes] / kappa;<br/>
b_nablaE_data[nablaE_sizes] = nablaE_data[nablaE_sizes] / kappa;<br/>
}<br/>
<br/>
// function to get exp(-(nablaW/kappa).^2)<br/>
power(b_nablaW_data, *(int32_T (*)[1])&nablaW_sizes, tmp_data, *(int32_T (*)[1])&tmp_sizes);<br/>
nablaE_sizes = 11;<br/>
power(b_nablaE_data, *(int32_T (*)[1])&nablaE_sizes, b_nablaW_data, *(int32_T (*)[1])&tmp_sizes);<br/>
<br/>
/* Discrete PDE solution. */<br/>
diff_sig_sizes[0] = 11;<br/>
for (nablaE_sizes = 0; nablaE_sizes < 11; nablaE_sizes++) <br/>
{<br/>
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]));<br/>
<br/>
printf("%gn",diff_sig_data); <br/>
}<br/>
<br/>
}<br/>
<br/>
}</stdlib.h></stdio.h><br/>
<br/>
View the full article
<br/>
<br/>
<br/>
<br/>
Im new in C I use visual studio 2010, I dont know how to display my output result, Ive tried to use printf, but it failed, the result is not indicate the truth of calculation in my program.<br/>
Attached link is my project code (complete file). http://www.sendspace.com/file/b2qs96" id="x_x_yui_3_2_0_7_1331945337614413 " target="_blank" style="color:#3a65bb; outline-width:0px; outline-style:initial; outline-color:initial; font-family:Arial,Helvetica,sans-serif; line-height:normal <span id="x_x_lw_1331953010_3 http://www.sendspace.com/file/b2qs96 <br/>
it related with anisotropic filtering. and below are some part of my code :<br/>
thanks in advance<br/>
<br/>
<span style="font-family:Verdana,Arial,sans-serif; line-height:normal main.cpp :<br style="font-family:Verdana,Arial,sans-serif; line-height:normal
<span style="font-family:Verdana,Arial,sans-serif; line-height:normal <br style="font-family:Verdana,Arial,sans-serif; line-height:normal
<span style="font-family:Verdana,Arial,sans-serif; line-height:normal #include <stdio.h style="font-family:Verdana, Arial, sans-serif;line-height:normal; <br/>
#include <stdlib.h><br/>
#include "anisodiff1D.h"<br/>
#include "anisodiff1D_initialize.h"<br/>
#include "anisodiff1D_terminate.h"<br/>
#include "rt_nonfinite.h"<br/>
#include "anisodiff1D.h"<br/>
#include "power.h"<br/>
#include "conv.h"<br/>
<br/>
int main(void)<br/>
{<br/>
real_T diff_sig_data[10];<br/>
int32_T diff_sig_sizes[1];<br/>
anisodiff1D_initialize();<br/>
anisodiff1D(diff_sig_data,diff_sig_sizes); <br/>
anisodiff1D_terminate();<br/>
system ("PAUSE");<br/>
return 0;<br/>
}<br/>
<br/>
<br/>
<br/>
anisodiff1D.cpp :<br/>
<br/>
/* Include files */<br/>
#include "rt_nonfinite.h"<br/>
#include "anisodiff1D.h"<br/>
#include "power.h"<br/>
#include "conv.h"<br/>
<br/>
void anisodiff1D(real_T diff_sig_data[11], int32_T diff_sig_sizes[1])<br/>
{<br/>
static const real_T b_sig[11] = { 10,10,11,10,9,10,13,10,10,13,9 };<br/>
<br/>
<br/>
int32_T t;<br/>
int32_T nablaW_sizes;<br/>
real_T nablaW_data[11];<br/>
int32_T nablaE_sizes;<br/>
real_T nablaE_data[11];<br/>
real_T b_nablaW_data[11];<br/>
real_T b_nablaE_data[11];<br/>
int32_T tmp_sizes;<br/>
real_T tmp_data[11];<br/>
int iteration=5;<br/>
int kappa=5.0;<br/>
<br/>
diff_sig_sizes[0] = 11;<br/>
memcpy((void *)&diff_sig_data[0], (void *)&b_sig[0], 11U * sizeof(real_T));<br/>
//real_T signal=diff_sig_data[nablaE_sizes];<br/>
<br/>
/* Anisotropic diffusion. */<br/>
for (t = 0; t < iteration; t++) //loop as long as number iteration<br/>
{<br/>
conv(diff_sig_data, diff_sig_sizes, nablaW_data, *(int32_T (*)[1])&nablaW_sizes); //do the convolution to distinguish between edge end not<br/>
b_conv(diff_sig_data, diff_sig_sizes, nablaE_data, *(int32_T (*)[1])&nablaE_sizes);<br/>
<br/>
/* Diffusion function. */<br/>
<br/>
nablaW_sizes = 11;<br/>
for (nablaE_sizes = 0; nablaE_sizes < 11; nablaE_sizes++) // the coefficient<br/>
{<br/>
b_nablaW_data[nablaE_sizes] = nablaW_data[nablaE_sizes] / kappa;<br/>
b_nablaE_data[nablaE_sizes] = nablaE_data[nablaE_sizes] / kappa;<br/>
}<br/>
<br/>
// function to get exp(-(nablaW/kappa).^2)<br/>
power(b_nablaW_data, *(int32_T (*)[1])&nablaW_sizes, tmp_data, *(int32_T (*)[1])&tmp_sizes);<br/>
nablaE_sizes = 11;<br/>
power(b_nablaE_data, *(int32_T (*)[1])&nablaE_sizes, b_nablaW_data, *(int32_T (*)[1])&tmp_sizes);<br/>
<br/>
/* Discrete PDE solution. */<br/>
diff_sig_sizes[0] = 11;<br/>
for (nablaE_sizes = 0; nablaE_sizes < 11; nablaE_sizes++) <br/>
{<br/>
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]));<br/>
<br/>
printf("%gn",diff_sig_data); <br/>
}<br/>
<br/>
}<br/>
<br/>
}</stdlib.h></stdio.h><br/>
<br/>
View the full article