void RegionsToSIFTDescriptors( PStack regions, PStack descriptors, int pb, int ob, int psize ) {
	
	if ( regions == NULL || descriptors == NULL ) return;
	
	if ( psize % 2 == 0 ) psize++;
	Image patch = CreateImage(psize*sqrt(2),psize*sqrt(2));
	Image rpatch = CreateImage(psize,psize);
	FStack orientations = NewFStack(15);
	
	int k;
	
	for (k=0;k<regions->stacksize;k++) {
		Region region = regions->items[k];
		RegionToPatch(region,region->image,patch,6.0);
		DeterminePatchOrientations(patch,orientations);
		while ( !FStackEmpty(orientations) ) {
			float orientation = PopFStack(orientations);
			RotateImage(patch,rpatch,orientation);
			float * newDescriptor = PCADescriptorFromPatch(rpatch);
			PushPStack(descriptors,NewDescriptor(region,36,3,newDescriptor));
		}
	}
	
	FreeFStack(orientations);
	FreeImage(patch); FreeImage(rpatch);

}
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) {

    FloatImage im;
    MatCopyToFloatMatrix(prhs[0], &im);

    bool use_default_patch = mxIsEmpty(prhs[1]);
    FloatImage patch_coord;
    PatchFeatureOpt opt;
    MatReadPatchFeatureOpt(prhs[2], &opt);

    if(!use_default_patch)
    {
        nlhs = 1;
        MatCopyToFloatMatrix(prhs[1], &patch_coord);
        InitPatchFeature(&im, &opt, &patch_coord);
    }
    else
    {
        nlhs = 2;
        InitPatchFeature(&im, &opt);
        plhs[1] = MatAllocateFloatMatrix(&patch_coord, opt.height, opt.width, 2);
    }

    FloatImage patch_feat;
    plhs[0] = MatAllocateFloatMatrix(&patch_feat, opt.length, opt.height * opt.width, 1);

    PatchFeature(&im, &patch_feat, &patch_coord, &opt);

    FreeImage(&im);
    if(!use_default_patch)
        FreeImage(&patch_coord);
}
Beispiel #3
0
	bool ClearCache(ThreadInfo* Thread){
		if(!Thread)
			return false;

		//notifying that image is not available
		ResetEvent(Thread->ImageAvailable);

		//waiting for cache
		WaitForSingleObject(Thread->CacheAvailable, INFINITE);

		//freeing cache
		CacheItem* Item = Thread->CacheData.First;
		Thread->CacheData.Size = 0;
		Thread->CacheData.First = 0;
		Thread->CacheData.Last = 0;
		
		//releasing cache
		ReleaseMutex(Thread->CacheAvailable);

		//restarting thread
		SetEvent(Thread->Running);

		//killing cache
		while(Item){
			FreeImage(Item->img);
			CacheItem* next = Item->next;
			delete(Item);
			Item = next;
		}

		return true;
	};
Beispiel #4
0
CTGALoader::~CTGALoader()
{
  if (filename)
    delete[] filename;


  FreeImage();
}
Beispiel #5
0
void TrashQNX(void)
{
  /* Remove sync timer */
  SetSyncTimer(0);
  /* Shut down audio */
  TrashAudio();
  /* Free output image buffer */
  FreeImage(&OutImg);
}
Beispiel #6
0
static void freeImages()
{
  int i;
  for (i = 1; i < MAXZOOM; i++) {
    if (Images[i])
	FreeImage(Images[i]);
    Images[i] = NULL;
  }
}
Beispiel #7
0
/* Change orientation of all following pages */
void TurnFollowing(int How, struct pagenode *pn)
{
    while (pn) {
	if (Pimage(pn)) {
	    FreeImage(Pimage(pn));
	    pn->extra = NULL;
	}
	pn->orient ^= How;
	pn = pn->next;
    }
}
Beispiel #8
0
void ChromaKeyOSD::Reinit(int i)
{
    // Make sure the buffer is the right size...
    QSize new_res(vf[i].width, vf[i].height);
    if (new_res != videoOutput->display_visible_rect.size())
    {
        FreeImage(i);
        AllocImage(i);
    }

    uint key = videoOutput->xv_colorkey;
    uint bpl = img[i]->bytes_per_line;

    // create chroma key line
    char *cln = (char*)av_malloc(bpl + 128);
    bzero(cln, bpl);
    int j  = max(videoOutput->display_video_rect.left() -
                 videoOutput->display_visible_rect.left(), 0);
    int ej = min(videoOutput->display_video_rect.left() +
                 videoOutput->display_video_rect.width(), vf[i].width);
    for (; j < ej; ++j)
        ((uint*)cln)[j] = key;

    // boboff assumes the smallest interlaced resolution is 480 lines - 5%
    int boboff = (int) round(
        ((double)videoOutput->display_video_rect.height()) / 456 - 0.00001);
    boboff = (videoOutput->m_deinterlacing &&
              videoOutput->m_deintfiltername == "bobdeint") ? boboff : 0;

    // calculate beginning and end of chromakey
    int cstart = min(max(videoOutput->display_video_rect.top() + boboff, 0),
                     vf[i].height - 1);
    int cend   = min(max(videoOutput->display_video_rect.top() +
                         videoOutput->display_video_rect.height(), 0),
                     vf[i].height);

    // Paint with borders and chromakey
    char *buf = shm_infos[i].shmaddr;
    int ldispy = min(max(videoOutput->display_visible_rect.top(), 0),
                     vf[i].height - 1);

    VERBOSE(VB_PLAYBACK, LOC + "cstart: "<<cstart<<"  cend: "<<cend);
    VERBOSE(VB_PLAYBACK, LOC + "ldispy: "<<ldispy<<" height: "<<vf[i].height);

    if (cstart > ldispy)
        bzero(buf + (ldispy * bpl), (cstart - ldispy) * bpl);
    for (j = cstart; j < cend; ++j)
        memcpy(buf + (j*bpl), cln, bpl);
    if (cend < vf[i].height)
        bzero(buf + (cend * bpl), (vf[i].height - cend) * bpl);

    av_free(cln);
}
Beispiel #9
0
void ConvertPngToGba(char *inputPath, char *outputPath, int numTiles, int bitDepth)
{
	struct Image image;

	image.bitDepth = bitDepth;

	ReadPng(inputPath, &image);

	WriteImage(outputPath, numTiles, bitDepth, &image, !image.hasPalette);

	FreeImage(&image);
}
Beispiel #10
0
VOID CZUIRender::DrawImage(HDC hDC, LPCTSTR lpszPath, RECT& rcSize, RECT& rcPaint)
{
	HBITMAP hBmp = NULL;
	HDC hMemDC = NULL;
	do 
	{
		if(NULL == lpszPath)
		{
			break;
		}

		hBmp = LoadImage(lpszPath);
		if(NULL == hBmp)
		{
			break;
		}

		hMemDC = ::CreateCompatibleDC(hDC);
		if(NULL == hMemDC)
		{
			break;
		}

		HBITMAP hOldBmp = (HBITMAP)::SelectObject(hMemDC, hBmp);

		// 
		RECT rc = {0};
		if((rcSize.left <= rcPaint.left) || (rcSize.top <= rcPaint.top))
		{
			rc.left = rcPaint.left;
			rc.top = rcPaint.top;
		}
		else
		{
			rc.left = rcSize.left;
			rc.top = rcSize.top;
		}
		rc.right = min(rcSize.right, rcPaint.right);
		rc.bottom = min(rcSize.bottom, rcPaint.bottom);

		::BitBlt(hDC, rc.left, rc.top, GetRectWidth(rc), GetRectHeight(rc), hMemDC, 0, 0, SRCCOPY);
		::SelectObject(hMemDC, hOldBmp);
	} while (0);
	if(hMemDC != NULL)
	{
		::DeleteDC(hMemDC);
	}
	if(hBmp != NULL)
	{
		FreeImage(hBmp);
	}
}
Beispiel #11
0
void *CELFFile::ReallocImage(size_t _size)
{
    if (_size > size && buffer != NULL)
    {
        unsigned char * new_buffer = new unsigned char [_size];
        memset(new_buffer,0xc3,_size);
        memcpy(new_buffer,buffer,size);
        FreeImage();
        size = _size;
        buffer = new_buffer;
    }
    return buffer;
}
Beispiel #12
0
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) {
    
    FloatImage im;
    PatchFeatureOpt opt;
    FloatImage patch_feat;
    
    // image input
    bool im_copy = MatReadFloatMatrix(prhs[0], &im);
    
    // option
    MatReadPatchFeatureOpt(prhs[1], &opt);
    
    
    opt.use_grids = false;
    // whether use default grids
    if(nrhs < 3 || mxIsEmpty(prhs[2]))
        opt.use_grids = true;    
    
    
    if(!opt.use_grids)
    {
        nlhs = 1;
        if(mxGetClassID(prhs[2]) != mxINT32_CLASS && mxGetM(prhs[2]) != 2)
            mexErrMsgTxt("Wrong Patch Coordinate Input");
        
        // self defined patch position
        opt.coord = (int *)mxGetPr(prhs[2]);               
        opt.num = mxGetN(prhs[2]);
    }
    else
    {
        nlhs = 2;
        opt.coord = NULL;
    }
    
    InitPatchFeature(&im, &opt);
    
    // allocate return variables
    plhs[0] = MatAllocateFloatMatrix(&patch_feat, opt.length, opt.num, 1);    
    if(opt.use_grids)        
        plhs[1] = MatAllocateGrids(&opt.grids);
    
//     mexPrintf("%d, %d\n", opt.length, opt.num);
    
    // process
    PatchFeature(&im, &patch_feat, &opt);
    
    if (im_copy)
        FreeImage(&im);
    
}
Beispiel #13
0
void FreeBirdImages(){
	FreeImage (BirdR1Image);
	FreeImage (BirdR2Image);
	FreeImage (BirdR3Image);
	FreeImage (BirdL1Image);
	FreeImage (BirdL2Image);
	FreeImage (BirdL3Image);
}
Beispiel #14
0
void TrashMSDOS(void)
{
  /* Restore keyboard IRQ */
  if(IRQ1Old) { _dos_setvect(0x09,IRQ1Old);IRQ1Old=0; }

  /* Restore timer IRQ */
  SetSyncTimer(0);

  /* Shut down audio */
  TrashAudio();

  /* Set text mode 80x25 */
  VGAText80();

  /* Free effect buffer */
  FreeImage(&OutScreen);
}
Beispiel #15
0
int ShowVideo(void)
{
  int SW,SH,J;

  /* Must have active video image */
  if(!VideoImg||!VideoImg->Data) return(0);

  switch(VGAMode)
  {
    case 1:  SW=320;SH=200;break;
    case 2:  SW=256;SH=240;break;
    case 3:  SW=800;SH=600;break;
    case 4:  SW=640;SH=480;break;
    default: return(0);
  }

  /* If applying image effects... */
  if(Effects&(EFF_SOFTEN|EFF_SCALE|EFF_TVLINES))
  {
    /* Allocate effect buffer if needed */
    if(!OutScreen.Data||(OutScreen.W!=SW)||(OutScreen.H!=SH))
    { FreeImage(&OutScreen);NewImage(&OutScreen,SW,SH); }

    /* If effect buffer present... */
    if(OutScreen.Data)
    {
      Image Img;
      int W,H;

      /* Apply effects */
      if(Effects&EFF_SOFTEN)
      {
        /* If video is squished, unsquish it */
        H = VideoW/VideoH;
        H = H>1? VideoH*H:VideoH;
        W = VideoH/VideoW;
        W = W>1? VideoW*W:VideoW;
        /* Try filling the screen */
        if(W*SH/H>SW) { H=H*SW/W;W=SW; } else { W=W*SH/H;H=SH; }
        /* Crop work region with the right W/H ratio */
        CropImage(&Img,&OutScreen,(SW-W)>>1,(SH-H)>>1,W,H);
        /* Scale VideoImg with softening algorithm */
        SoftenImage(&Img,VideoImg,VideoX,VideoY,VideoW,VideoH);
      }
      else if(Effects&EFF_SCALE)
Beispiel #16
0
void ConvertGbaToPng(char *inputPath, char *outputPath, int width, int bitDepth, char *paletteFilePath, bool hasTransparency)
{
	struct Image image;

	if (paletteFilePath != NULL) {
		ReadGbaPalette(paletteFilePath, &image.palette);
		image.hasPalette = true;
	} else {
		image.hasPalette = false;
	}

	ReadImage(inputPath, width, bitDepth, &image, !image.hasPalette);

	image.hasTransparency = hasTransparency;

	WritePng(outputPath, &image);

	FreeImage(&image);
}
Beispiel #17
0
Datei: it.c Projekt: cran/PET
/***************************************************************
[NAME]
SaveIteration

[SYNOPSIS]
void SaveIteration(Vector *MyVector, 
                   int iteration, 
                   char *filename)

[DESCRIPTION] 

This function is used to save a series of images while iterating. The
function saves an image with the specified outputname + a number
indicating which iteration the picture represents.

[USAGE]
{\tt SaveIteration(TestVector, 123, "testImage");}

Saves the vector {\tt TestVector} as the image `{\tt testimage.123.pet}'.

[REVISION]
Dec. 94, JJJ
July 2006, Joern Schulz
***************************************************************/
void SaveIteration(Vector *MyVector, int iteration, char *filename)
{
  char outfilename[100];
  char itstr[10];
  Image *NewImage;

  strcpy(outfilename,filename);
  sprintf(itstr,".%d",iteration);  
  strcat(outfilename,itstr);

  NewImage=VectorToImage(MyVector,itINI.XSamples,itINI.YSamples);

  RenameImage(NewImage,outfilename);
  NewImage->DeltaX=itINI.DeltaX;
  NewImage->DeltaY=itINI.DeltaY;
  NewImage->Xmin=itINI.Xmin;
  NewImage->Ymin=itINI.Ymin;
  ScaleImage(NewImage);
  WritePET(NewImage);
  FreeImage(NewImage);
}
Beispiel #18
0
void TopLevel::FreeFax()
{
  if(display_is_setup)
    XClearWindow(qtdisplay, Win);

  freeImages();

  pagenode *pn;
  for (pn = firstpage; pn; pn = pn->next){
    if(Pimage(pn)){
       FreeImage(Pimage(pn));
       pn->extra = NULL;
    }
  }

  Image = NULL;

  for (pn = firstpage; pn; pn = pn->next){
    if(pn->pathname){
       free(pn->pathname);
    }
  }


  if(firstpage){
    for(pn = firstpage->next; pn; pn = pn->next){
      if(pn->prev){
	free(pn->prev);
      }
    }
  }

  if(lastpage)
    free(lastpage);

  firstpage = lastpage = viewpage = thispage = auxpage = NULL;

  uiUpdate();
}
Beispiel #19
0
int main(int argc, char **argv)
	{
	char *src_filespec, *dst_filespec ;
	static OPTION options[] =
		{
		{"Hue (%.0f deg)",		AdjustHue,			-45},
		{"Saturation (%.1f)",	AdjustSaturation,	 70},
		{"Value (%.1f)",		AdjustValue,		120},
		{NULL,					NULL,				  0}
		} ;
	OPTION *option ;
	IMAGE *image ;

	if (argc != 3 && argc != 4)
		{
		fprintf(stderr, "Usage: %s src-file dst-file {option#}\n", argv[0]) ;
		exit(255) ;
		}

	src_filespec = argv[1] ;
	dst_filespec = argv[2] ;

	image = ReadBMP24(src_filespec) ;

	if ((option = GetOption(argc, argv, options))== NULL)
		{
		fprintf(stderr, "Usage: %s src-file dst-file {option#}\n", argv[0]) ;
		exit(255) ;
		}

	image = (option->function)(image, option->param) ;

	WriteBMP24(dst_filespec, image) ;
	FreeImage(image) ;
	DisplayImage(dst_filespec, option->format, option->param) ;

	return 0 ;
	}
Beispiel #20
0
int InitGL_Texture (void)
{
    GLuint texName;
    GLint CurrentTexWidth, CurrentTexHeight;

    glClearColor (0.0, 0.0, 0.0, 0.0);
    glEnable (GL_DEPTH_TEST);

    glGenTextures (1, &texName);
    glBindTexture (GL_TEXTURE_2D, texName);

    glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);

    CreateImage ( 1);
    CurrentTexWidth = TexWidth;
    CurrentTexHeight = TexHeight;

    glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, CurrentTexWidth, CurrentTexHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, ImageData1);
    FreeImage (1);

    return GL_TRUE;
}
Beispiel #21
0
void ipu_image_stop()
{
	int lcd_level = 0;
	lcd_level = kernel_ioctl(&lcd_level,KERNEL_BACKLIGHT_CTRL);
	lcd_ioctl(0, IOCTL_IPU_TO_DMA1);
	SetVideoOutMode(NULL);
	FreeImage();
	
	int pmdata = -1;
	int curlevel = kernel_ioctl(&pmdata,KERNEL_PM_CONTROL);
	if(curlevel != init_pm_level)
	{
		
		int enablelcd = 0;
		kernel_ioctl(&enablelcd,KERNEL_LCD_CTRL);
		kernel_ioctl(&init_pm_level,KERNEL_PM_CONTROL);
		enablelcd = 1;
		kernel_ioctl(&enablelcd,KERNEL_LCD_CTRL);
		
	}	
	usec_sleep(150000);
	// kernel_ioctl(&lcd_level,KERNEL_BACKLIGHT_CTRL);

}
LoadTexture::~LoadTexture(void)
{
	FreeImage();           // 释放内存 
}
Beispiel #23
0
// process image
void Viewer::Update(Png *png1)
{
    struct p2d_globals_struct *p2dg = NULL;
    P2D *p2d = NULL;
    int rv;
    int dens_x, dens_y, dens_units;
    unsigned char tmpr,tmpg,tmpb;
    HCURSOR hcur=NULL;
    int cursor_flag=0;
    struct viewer_read_ctx read_ctx;

    m_errorflag=0;
    FreeImage();

    if(!png1) goto abort;

    if(png1->m_imgtype==IMG_MNG) {
        m_errorflag=1;
        StringCchCopy(m_errormsg,200,_T("Viewer doesn") SYM_RSQUO _T("t support MNG files."));
        goto abort;
    }
    else if(png1->m_imgtype==IMG_JNG) {
        m_errorflag=1;
        StringCchCopy(m_errormsg,200,_T("Viewer doesn") SYM_RSQUO _T("t support JNG files."));
        goto abort;
    }

    hcur=SetCursor(LoadCursor(NULL,IDC_WAIT));
    cursor_flag=1;

    if(!globals.viewer_p2d_globals) {
        globals.viewer_p2d_globals = (void*)p2d_create_globals();
    }
    p2d = p2d_init((p2d_globals_struct*)globals.viewer_p2d_globals);

    png1->stream_file_start();
    p2d_set_png_read_fn(p2d,my_read_fn);

    read_ctx.png = png1;
    p2d_set_userdata(p2d,(void*)&read_ctx);

    p2d_enable_color_correction(p2d, globals.use_gamma?1:0);

    p2d_set_use_file_bg(p2d,globals.use_imagebg?1:0);
    if(globals.use_custombg) {
        p2d_set_custom_bg(p2d,GetRValue(globals.custombgcolor),
                          GetGValue(globals.custombgcolor),GetBValue(globals.custombgcolor));
    }

    rv=p2d_run(p2d);
    if(rv!=PNGD_E_SUCCESS) {
        lstrcpyn(m_errormsg,p2d_get_error_msg(p2d),200);
        m_errorflag=1;
        goto abort;
    }
    rv=p2d_get_dib(p2d,&m_dib);
    m_dib_size = p2d_get_dib_size(p2d);
    rv=p2d_get_dibbits(p2d, &m_bits);

    m_adjwidth = m_dib->biWidth;
    m_adjheight = m_dib->biHeight;

    if(globals.viewer_correct_nonsquare)
        rv=p2d_get_density(p2d, &dens_x, &dens_y, &dens_units);
    else
        rv=0;

    if(rv) {
        if(dens_x!=dens_y && dens_x>0 && dens_y>0 &&
                10*dens_x>dens_y && 10*dens_y>dens_x)
        {
            if(dens_x>dens_y) {
                m_adjheight = (int) (0.5+ (double)m_adjheight * ((double)dens_x/(double)dens_y) );
            }
            else {
                m_adjwidth = (int) (0.5+ (double)m_adjwidth * ((double)dens_y/(double)dens_x) );
            }
        }
    }

    CalcStretchedSize();

    m_imghasbgcolor=0;
    if(p2d_get_bgcolor(p2d,&tmpr,&tmpg,&tmpb)) {
        m_imghasbgcolor=1;
        m_imgbgcolor = RGB(tmpr,tmpg,tmpb);
    }

abort:
    if(p2d) p2d_done(p2d);

    if(m_hwndViewer) {
        InvalidateRect(m_hwndViewer,NULL,TRUE);
    }

    if(cursor_flag) SetCursor(hcur);
}
Beispiel #24
0
Viewer::~Viewer()
{
    FreeImage();
    globals.viewer_imgpos_x = m_imgpos_x;
    globals.viewer_imgpos_y = m_imgpos_y;
}
Beispiel #25
0
Datei: it.c Projekt: cran/PET
/***************************************************************
[NAME]
main

[SYNOPSIS]
void main(int argc, char *argv[])

[DESCRIPTION]
This is the main function which controls the program.

[USAGE]
{\tt it test.ini}

Starts the main program with the parameteres specified in {\tt test.ini}.

[REVISION]
March 96, JJJ and PT\\
April 2, 96 PT (Moved last call to clock - error in SGI CC)
July 2006,  Modification of the complete routine for the R calling.
***************************************************************/
void it(double *InImage, double *OutImage, int *StartImageTrue, double *StartImage, char **mode, int *UseFast, char **RadonKernel, char **IterationsType, int *Iterations, int *SaveIterations, char **SaveIterationsName, double *LowestALevel, double *ConstrainMin, double *ConstrainMax, double *Alpha, double *Beta, double *Regularization, int *KernelFileSave, char **KernelFileName, char **RefFileName, int *ThetaSamples, double *ThetaMin, double *DeltaTheta, int *RhoSamples, double *RhoMin, double *DeltaRho, double *Xmin, double *Ymin, double *DeltaX, double *DeltaY, int *XSamples, int *YSamples, int *OverSamp, char **DebugLevel )
{
  int RealTid1,RealTid2,n;
  float Tid, tempsuma, tempsumb, mean;
  char Value[100];
  Vector *xvector, *tempvector, *bvector;

  GetDateTime(Value,_RealTime);
  sscanf(Value,"%i",&RealTid1);
  Tid=clock();

  if (strstr(*DebugLevel,"HardCore")) DebugNiveau=_DHardCore;
  else DebugNiveau=_DNormal;
      
  Print(_DNormal,"\n********************************************\n\n");
  Print(_DNormal,"Iterative Reconstruction program version 2.0\n");
  Print(_DNormal,"    Peter Toft and Jesper James Jensen\n");
  Print(_DNormal,"     Implemented in R by Joern Schulz\n");
  Print(_DNormal,"\n********************************************\n");


  ReadItArgs("InputData", *mode, UseFast, *RadonKernel, *IterationsType, Iterations, SaveIterations, *SaveIterationsName, LowestALevel, ConstrainMin, ConstrainMax, Alpha, Beta, Regularization, KernelFileSave, *KernelFileName, *RefFileName, ThetaSamples, ThetaMin, DeltaTheta, RhoSamples,  RhoMin, DeltaRho, Xmin, Ymin, DeltaX, DeltaY, XSamples, YSamples, OverSamp, *DebugLevel);  
  
  // ==================================================================
  // Initialization of radon-image and the System-Matrix A
  
  if (itINI.IsFast)  AMatrix=GenerateAMatrix();
  
  bvector=DoubleToFloatVector(InImage, itINI.ThetaSamples, itINI.RhoSamples);

  // ==================================================================
  // Regularisation and initialisation of a Start-Image

  /* If regularisation is used, concatenate the bvector with zeroes */
  if (itINI.Regularization>0) 
    VectorCat(bvector,InitVector(AMatrix->M-bvector->N));

  if (*StartImageTrue) {
    Print(_DDetail, "A StartImage was specified. \n");
    xvector=DoubleToFloatVector(StartImage, itINI.XSamples, itINI.YSamples);
  }
  else {
    xvector=InitVector(itINI.XSamples*itINI.YSamples);
    if (itINI.IsFast) {
      /* The fast version, we can use the a-matrix */
      tempsuma=0; tempsumb=0;
      tempvector=SumRowSparseMatrix(AMatrix);
      for(n=0; n<tempvector->N; n++)
        tempsuma+=tempvector->value[n];
      for(n=0; n<bvector->N; n++)
        tempsumb+=bvector->value[n];
      mean=tempsumb/tempsuma;
      for(n=0; n<xvector->N; n++)
        xvector->value[n]=mean;
    } else {
      /* we have to estimate the mean value */
      tempsumb=0;
      for(n=0; n<bvector->N; n++)
        tempsumb+=bvector->value[n];
      mean=tempsumb/(itINI.ThetaSamples*itINI.RhoSamples*itINI.XSamples*itINI.DeltaX);
      for(n=0; n<xvector->N; n++)
        xvector->value[n]=mean;
    }    
    //Print(_DNormal,"Estimated mean of output image: %f \n",mean);
    Print(_DNormal,"Image-Initialization with: %f \n",mean);
  }

  // ==================================================================
  // Choice the corresponding Algorithm
  
  switch (itINI.Algorithm){           /* Main choice of algorithm */
    case _CG:   
      if (itINI.IsFast)
        MyImage=FAST_CG(AMatrix,xvector,bvector);
      else
        MyImage=SLOW_CG(xvector,bvector);                       
      break;
    case _EM:
      if (itINI.IsFast)
        MyImage=FAST_EM(AMatrix,xvector, bvector);                       
      else
        MyImage=SLOW_EM(xvector, bvector);                       
      break;
    case _ART:   
      if (itINI.IsFast)
        MyImage=FAST_ART(AMatrix,xvector,bvector);
      else
        MyImage=SLOW_ART(xvector,bvector);
      break;
  }
  
  ScaleImage(MyImage);
  Print(_DDetail,"\n");
  PrintStats(_DDetail, MyImage);

  // ==================================================================
  // Storage of reconstructed data and empty out the memory.
  
  ImageToFloat(OutImage, MyImage);
  FreeImage(MyImage);
  FreeVector(xvector);
  FreeVector(bvector);
  if (itINI.IsFast)
    FreeSparseMatrix(AMatrix);
  
  // ==================================================================
  // Calculation of the time-consuming.
  
  Tid=(clock()-Tid)/(float)CLOCKS_PER_SEC;
  GetDateTime(Value,_RealTime);
  sscanf(Value,"%i",&RealTid2);
  Print(_DNormal,"IT: Program was active for %.2f seconds\n",Tid) ;
  Print(_DNormal,"    World time elapsed %d seconds\n",
	(RealTid2-RealTid1));
  Print(_DNormal,"    Program used %.2f %% cpu time\n",
         Tid/((float)RealTid2-RealTid1)*100);
  Print(_DNormal,"\n");

}
Beispiel #26
0
void ipu_image_stop()
{
	lcd_ioctl(0, IOCTL_IPU_TO_DMA1);
	SetVideoOutMode(NULL);
	FreeImage();
}
Beispiel #27
0
wxIcon
wxIconManager::GetIcon(const String &iconNameOrig)
{
   String iconName = iconNameOrig;

   strutil_tolower(iconName);
   wxLogTrace(wxTraceIconLoading, _T("wxIconManager::GetIcon(%s) called..."),
              iconNameOrig.c_str());

   wxIcon icon;

   // first always look in the cache
   if ( FindInCache(iconName, &icon) )
      return icon;

   // next step: try to load the icon files .png,.xpm,.gif:
   if(m_GlobalDir.Length())
   {
      PathFinder pf(READ_APPCONFIG(MP_ICONPATH));

#ifdef M_TOP_SOURCEDIR
      // look in the source directory to make it possible to use the program
      // without installing it
      pf.AddPaths(String(M_TOP_SOURCEDIR) + _T("/src/icons"));
      pf.AddPaths(String(M_TOP_SOURCEDIR) + _T("/res"));
#endif // M_TOP_SOURCEDIR

      pf.AddPaths(m_GlobalDir, false);
      if(ms_IconPath.Length() > 0)
         pf.AddPaths(ms_IconPath,false, true /*prepend */);
      pf.AddPaths(m_LocalDir, false);
      if(m_SubDir.Length() > 1)  // 1 == "/" == empty
      {
         pf.AddPaths(m_GlobalDir+m_SubDir, false, true);
         pf.AddPaths(m_LocalDir+m_SubDir, false, true);
      }

      String name;
      for ( int ext = 0; wxIconManagerFileExtensions[ext]; ext++ )
      {
         // use iconNameOrig here to preserve the original case
         name = pf.FindFile(iconNameOrig + wxIconManagerFileExtensions[ext]);

         // but if it's not found, also fall back to the usual lower case
         if ( name.empty() )
         {
            name = pf.FindFile(iconName + wxIconManagerFileExtensions[ext]);
         }

         if ( !name.empty() )
         {
            ms_IconPath = name.BeforeLast('/');

            if ( !icon.LoadFile(name, wxBITMAP_TYPE_ANY) )
            {
               // try to load it via conversion to XPM
               char **ptr = LoadImageXpm(name);
               if(ptr)
               {
                  icon = wxIcon(ptr);
                  FreeImage(ptr);
               }
            }

            if ( icon.Ok() )
            {
               IconData  id;
               id.iconRef = icon;
               id.iconName = iconName;
               wxLogTrace(wxTraceIconLoading, _T("... icon found in '%s'"),
                          name.c_str());
               m_iconList.push_front(id);
               return icon;
            }
         }
     } // for all extensions
   } // if globaldir is not empty

#ifdef OS_WIN
   // last, look in the resources
   {
      icon = wxIcon(iconNameOrig);
      if ( icon.Ok() ) {
         wxLogTrace(wxTraceIconLoading, _T("... icon found in the ressources."));
         return icon;
      }

      // ok, it failed - now do all the usual stuff
   }
#endif  //Windows

   wxLogTrace(wxTraceIconLoading, _T("... icon not found."));

   return m_unknownIcon;
}
Beispiel #28
0
void FreeCloudImages(){
	FreeImage(CloudBigLineImage);
	FreeImage(CloudLineImage);
	FreeImage(CloudBigImage);
	FreeImage(CloudImage);
}
Beispiel #29
0
/** 析构函数 */
TGALoad::~TGALoad()
{
	FreeImage();
}
Beispiel #30
0
//析构函数
BMPLoad::~BMPLoad()
{
	FreeImage();			//释放图像数据占据的内存
}