2 Replies - 5950 Views - Last Post: 13 March 2008 - 04:16 PM Rate Topic: -----

#1 ashraf_leaf  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 13-March 08

run a C program in visual basic

Posted 13 March 2008 - 02:33 PM

Hi folks,


I want run a c program in visual basic. How can I do this? Actually this program is for wiener filtering. I want to change the parameter of K in visual basic and want to see the different image output. For your information I use mvc++6.

Thanks in advance.

Ashraf

code is given for your understanding.




/* Wiener filter - restoration using only non-zero PSF values */

#define MAX
#include "fftlib.h"

int
main (int argc, char *argv[])
{
	int n=0, nr, nc;
	IMAGE im1, p;
	COMPLEX_IMAGE fft1, fft2;
	float x, xi, H, K, t;
	int i,j, k;

	printf ("Image Restoration System module 5 - Weiner filter\n");

/* Try to open standard image files.  */
	if (argc < 4)
	{
		printf ("WEINER input psf output\n\n");
		exit (0);
	}

	im1 = Input_PBM (argv[1]);
	if (im1 == 0)
	{
	  printf ("No such file as '%s'\n", argv[1]);
	  exit(1);
	}

	p = Input_PBM (argv[2]);
	if (p == 0)
	{
	  printf ("No such file as '%s'\n", argv[2]);
	  exit(1);
	}


	if (im1->info->nr != im1->info->nc)
	{
		printf ("Input image is not square. Use ALIGN.\n");
		exit(0);
	}

		if (p->info->nr != p->info->nc)
		{
				printf ("PSF image is not square. Use ALIGN.\n");
				exit(0);
		}

	if (im1->info->nr != p->info->nr)
	{
		printf ("Input and PSF images differ in size.\n");
		exit (0);
	}
	nr = im1->info->nr; nc = im1->info->nc;
	printf("The number of rows of the image:%d\n", nr);
	printf("The number of columns of the image:%d\n", nc);
	image_fftoc (im1, &fft1);
	normalize_set ();
	image_fftoc (p,   &fft2);
	normalize_clear();

	printf ("Enter K: ");
	scanf ("%f", &K);

	for (i=0; i<nr; i++)
	  for (j=0; j<nc; j++)
	  {
		x = fft2[i][j];	xi = fft2[i][j+nc];
		H = pix_cnorm (x, xi);
		if (H == 0.0)
		{
		  fft1[i][j] = fft1[i][j+n] = 0.0;
		  continue;
		}
		t = H/(H+K);
		cdiv (t, 0.0, &x, &xi);
		cprod (fft1[i][j], fft1[i][j+nc], &x, &xi);
		fft1[i][j] = x; fft1[i][j+nc] = xi;
	  }
	
	freecomplex (fft2); fft2 = (COMPLEX_IMAGE)0;

	image_fftinvoc (fft1, &fft2);
	freecomplex (fft1); fft1 = (COMPLEX_IMAGE)0;

	filt_toint (fft2, p, 0);
	Output_PBM (p, argv[3]);
	
}




Is This A Good Question/Topic? 0
  • +

Replies To: run a C program in visual basic

#2 Jingle  Icon User is offline

  • D.I.C Regular

Reputation: 9
  • View blog
  • Posts: 317
  • Joined: 20-October 07

Re: run a C program in visual basic

Posted 13 March 2008 - 03:47 PM

you should probably try the Visual Basic forum

you should probably try the Visual Basic forum
Was This Post Helpful? 0
  • +
  • -

#3 ashraf_leaf  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 13-March 08

Re: run a C program in visual basic

Posted 13 March 2008 - 04:16 PM

View PostJingle, on 13 Mar, 2008 - 03:47 PM, said:

you should probably try the Visual Basic forum

you should probably try the Visual Basic forum

thanks
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1