亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? lloyd0.c

?? Vector Quantization壓縮算法
?? C
字號:
/****************************************************************************** * * NAME *    lloyd0.c *    J. R. Goldschneider 4/93 * * MODIFICATIONS *    11/93 This was changed slightly to ensure that if distortion is zero, *    codebooksize is set to size so that the program will exit gracefully. JRG *    5/94 Cleaned up a calloc mistake and changed the number of times to try *    to split empty cells from size to fixed value MAX_SPLIT_ATTEMPTS. JRG * * SYNOPSIS *    lloyd0(codebook,size) * * DESCRIPTION *    lloyd0 performs the generalized lloyd algorithm for the given codebook *    with size codewords.  lloyd exits with a codebook if the percent change *    in distortion from one pass to the next is less than threshold. *    If there are any empty cells, lloyd will try to split the most *    populous cells.  lloyd will attempt to split cells up to size *    times unless the distortion is zero.  If the distortion is zero, then *    those codewords are returned and the global variable codebooksize  *    is modified since large codebooks can no longer be made. *    This ensures that the zero distortion codebook is returned to the *    user, but allows that the program stdvq terminate normally. If *    the write_all_codebooks option is not selected that the program *    will terminate. *     * RETURN VALUE *    lloyd returns a positive number, i.e. the distortion, if a codebook *    is found.  A negative number is returned if there is not enough *    memory for temporary storage and computations or if a codebook *    cannot be found.  There are two possibilities for the latter case: *    there are empty cells which could not be filled after size attempts, *    or there are permanently empty cells, zero distortion, and *    the write_all_codebooks option was not selected. * * PARAMETERS *    codebook contains the codewords. *    size is the current number of words in the codebook. * * CALLS *    splitcodewords() * *****************************************************************************/#include <stdio.h>#include <string.h>#include <math.h>#include "vq.h"#include "stdvq.def"#include "stdvq.h"double lloyd0(codebook,size)     double **codebook;     long   size;{  double  distortion;     /* distortion between training set and codebook */  double  olddistortion;  /* distortion from the previous pass of GLA */  double  bestdistortion; /* distortion between 1 vector and best codeword */  double  tempdistortion; /* temporary variable */  double  temp;           /* temporary variable */  long    numbervectors;  /* number of vectors used */  long    i,j,n;          /* counters and indices */  long    pass;           /* the number of attempts to split empty cells */  long    bestcodeword;   /* index of the best codeword for a given vector */  long    emptycells;     /* number of empty cells */  long    *count;         /* array of number of vectors per region */  double  **centroid;     /* array of centroids of each voronoi region */  DATA    *tempvector;    /* the training vector */  /* allocate memory for the centroids, temporary vector, and count vector */  if (!(centroid = (double **) calloc(size,sizeof(double *))) ||      !(tempvector = (DATA *) calloc(dimension, sizeof(DATA))) ||      !(count = (long *) calloc(size, sizeof(long)))) {    fprintf(stderr,"%s: %s\n",programname,NOMEMORY);    return(-1.0);  }  /* allocate memory for the dimension of each centroid, and initialize the   * the centroids and countnumber */   for(i=0; i < size; i++) {    if (!(centroid[i] = (double *) calloc(dimension,sizeof(double)))) {      fprintf(stderr,"%s: %s\n",programname,NOMEMORY);      return(-1.0);    }    for (j = 0; j < dimension; j++) {      centroid[i][j] = 0.0;    }    count[i] = 0;  }  /* do the lloyd iteration.  Use the nearest neighbor condition to     find the cells.  Then find the centroid of each cell. */  olddistortion = HUGE; /* first pass requires very large distortion */  emptycells = 1; /* ensures that loop is done at least one time */  pass = 0; /* no empty cells have been found yet */  do {    /* compute distortion */    distortion = 0.0;    rewind(trainingfile);    /* read in vector and find the closest codeword */    while (fread(tempvector, sizeof(DATA), dimension, trainingfile) ==	   dimension && !feof(trainingfile) && !ferror(trainingfile) ) {      bestdistortion = HUGE; /* keep convention that ties go to lower index */      bestcodeword = 0;      for (i = 0; i < size; i++){ /* find the best codeword */	tempdistortion = 0.0;	for (j = 0; j < dimension; j++) {	  temp = ( (double) tempvector[j]) - codebook[i][j];	  tempdistortion += temp*temp;	  if (tempdistortion > bestdistortion) j = dimension;	}	if (tempdistortion < bestdistortion) {	  bestdistortion = tempdistortion;	  bestcodeword = i;	}	/* if the bestdistortion is 0.0, the best codeword is found */	if (bestdistortion == 0.0) i=size;      }      count[bestcodeword]++;      for (j = 0; j < dimension; j++){	centroid[bestcodeword][j] += (double) tempvector[j];      }      distortion += bestdistortion;    }    /* all training vectors have been encoded */    /* normalize the distortion */    numbervectors = 0;    for (i = 0; i < size; i++) {      numbervectors += count[i];    }    if(numbervectors == 0) {      fprintf(stderr,"%s: %s: %s\n",programname,trainingname,NOTFOUND);      return(-1.0);    }    distortion /= (double) numbervectors;    if(distortion < 0) {      fprintf(stderr,"%s: %s: %s\n",programname,OVERFLOWED,ABORT_STDVQ);      return(-1.0);    }    /* if distortion = 0.0 or if change in distortion < threshold AND       if there aren't any empty cells, exit */    if ( (emptycells == 0) && 	((distortion == 0.0) || 	 ( (olddistortion - distortion)/distortion < threshold)) ) {      /* if distortion is 0, let the program exit gracefully */      if(distortion == 0 && size < codebooksize) {	fprintf(stderr,"%s %d\n",STOP,size);	size = codebooksize;      }      return(distortion);    }    /* Find the number of empty cells */    emptycells = 0;    for (i = 0; i < size; i++) {      if (count[i] == 0) ++emptycells;    }    /* no empty cells, find new centroids and reinitialize for next pass */    if (emptycells == 0) {      for (i = 0; i < size; i++) {	for (j = 0; j < dimension; j++ ) {	  codebook[i][j] = centroid [i][j] / (double) count[i];	  centroid[i][j] = 0.0;	}	count[i] = 0;      }      olddistortion = distortion;    }        /* there are empty cells, split the most populous codewords. try again */    else {       /* if the distortion is 0, can't split cells, exit program gracefully */      if (distortion == 0.0) { 	if (emptycells > 1) {	  fprintf(stderr,"%s %d %s %d\n",		  NOFILL,emptycells,EMPTYCELLS,size);	}	else {	  fprintf(stderr,"%s %d %s %d\n",		  NOFILL,emptycells,EMPTYCELL,size);	}	codebooksize = size - emptycells;	fprintf(stderr,"%s %d\n",STOP,codebooksize);	return(distortion);      }            /* If there have been too many attempts to fill cells, exit program */       if (pass == MAX_SPLIT_ATTEMPTS) { 	if (emptycells > 1) {	  fprintf(stderr,"%s %d %s %d\n",NOFILL,emptycells,EMPTYCELLS,size);	}	else {	  fprintf(stderr,"%s %d %s %d\n",NOFILL,emptycells,EMPTYCELL,size);	}	fprintf(stderr,"%s\n",ABORT_STDVQ);	return(-1.0);      }      /* consolidate the nonempty codewords at the beginning of the	 array with the most populous cells first. */      for(n = 0; n < size - emptycells; n++) {	j = 0;	bestcodeword = 0;	for (i = 0; i < size; i++) {	  if (count[i] > j) {	    j = count[i];	    bestcodeword = i;	  }	}		for (j = 0; j < dimension; j++ ) { /* find centroid */	  codebook[n][j] = centroid[bestcodeword][j] / 	    (double) count[bestcodeword];	  centroid[bestcodeword][j] = 0.0;	}	count[bestcodeword] = 0;            }            /* try getting new codewords */      if (emptycells > 1) {	fprintf(stderr,"%s %d %s %d\n",TRYFILL,emptycells,EMPTYCELLS,size);      }      else {	fprintf(stderr,"%s %d %s %d\n",TRYFILL,emptycells,EMPTYCELL,size);      }      fflush(stderr);            /* split the required number of codewords */      splitcodewords(codebook, size - emptycells, size, pass);      olddistortion = distortion;      pass++;    }  } while (TRUE);  /* should never get here */  return(-1.0);}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩精品一二三区| 韩国精品主播一区二区在线观看| 欧美刺激脚交jootjob| 91电影在线观看| 91女厕偷拍女厕偷拍高清| 成人高清免费观看| 99re这里只有精品首页| 国产成人自拍在线| 不卡高清视频专区| 色香色香欲天天天影视综合网| 91在线国产福利| 欧洲精品中文字幕| 91国产福利在线| 欧美午夜精品免费| 91麻豆精品国产| 精品国产乱码久久久久久老虎 | 一区二区三区中文字幕电影| 亚洲精品国产精华液| 亚洲图片一区二区| 视频精品一区二区| 精品一区二区三区的国产在线播放| 国产成人精品影视| 欧美在线观看18| 日韩一区二区免费在线观看| 国产日产欧美精品一区二区三区| 中文字幕一区二区三区蜜月 | 日韩视频不卡中文| 国产日韩一级二级三级| 一区二区三区成人在线视频| 免费成人在线网站| 99re成人在线| 精品少妇一区二区| 亚洲黄色性网站| 精东粉嫩av免费一区二区三区| jvid福利写真一区二区三区| 91亚洲精品一区二区乱码| 91精品国模一区二区三区| 欧美国产日韩a欧美在线观看| 性做久久久久久久免费看| 国产福利91精品| 日韩欧美自拍偷拍| 一区二区三区中文在线观看| 国产美女精品人人做人人爽| 91麻豆国产精品久久| 精品av久久707| 日韩成人一区二区三区在线观看| 国产福利一区二区| 欧美精品v日韩精品v韩国精品v| 国产蜜臀97一区二区三区| 久久激情五月激情| 欧美亚洲精品一区| 国产精品免费av| 国产麻豆精品视频| 日韩三级伦理片妻子的秘密按摩| 亚洲综合色网站| 99国产精品国产精品久久| 久久精品在线观看| 国产精品一区免费视频| 日韩视频免费直播| 免费成人av在线| 欧美一级一级性生活免费录像| 一区二区三区在线视频免费 | 国产精品久久久久久久久免费丝袜 | 亚洲欧洲日产国产综合网| 精品亚洲porn| 日韩一区二区三区三四区视频在线观看 | 日本v片在线高清不卡在线观看| 91首页免费视频| 中文av字幕一区| 99久久99久久精品免费看蜜桃| 日本一区二区成人在线| 国产成人aaaa| 国产精品久久久久久亚洲毛片| 福利一区二区在线| 久久久91精品国产一区二区精品| 国产精品一区二区黑丝| 久久精品男人天堂av| 粉嫩av亚洲一区二区图片| 国产精品美女视频| 一本久道中文字幕精品亚洲嫩| 自拍偷拍亚洲综合| 欧美揉bbbbb揉bbbbb| 午夜视频一区二区| 日韩精品影音先锋| 精品亚洲成av人在线观看| 久久色中文字幕| 成人av影视在线观看| 一级日本不卡的影视| 欧美美女bb生活片| 激情六月婷婷久久| 国产精品毛片a∨一区二区三区| 日韩欧美在线影院| 国内精品视频666| 国产精品无人区| 在线观看免费亚洲| 美女网站一区二区| 国产精品久久久久久久久久久免费看| 不卡的看片网站| 日本亚洲最大的色成网站www| 欧美日本国产视频| 国产黄色精品视频| 亚洲午夜影视影院在线观看| 日韩三级在线免费观看| av在线不卡网| 欧美a级一区二区| 亚洲日本护士毛茸茸| 欧美一级视频精品观看| www.日韩大片| 青青草伊人久久| 亚洲精品大片www| 717成人午夜免费福利电影| 国产a精品视频| 日韩二区在线观看| 亚洲视频狠狠干| 日韩一级完整毛片| 色播五月激情综合网| 国产一区在线观看视频| 亚洲一二三区不卡| 欧美极品aⅴ影院| 亚洲精选免费视频| 日韩美一区二区三区| 欧美视频在线一区二区三区| 高清久久久久久| 黑人巨大精品欧美黑白配亚洲| 亚洲国产一区视频| 国产视频一区二区在线观看| 5566中文字幕一区二区电影| 91蜜桃免费观看视频| 成人综合婷婷国产精品久久| 蜜桃一区二区三区在线观看| 亚洲二区在线观看| 亚洲精品福利视频网站| 中文字幕日韩一区| 精品伦理精品一区| 日韩欧美黄色影院| 欧美人体做爰大胆视频| 欧美一a一片一级一片| 97se亚洲国产综合自在线观| 不卡一区中文字幕| 国产精品18久久久| 国产九色精品成人porny| 国内精品伊人久久久久av影院 | 91亚洲国产成人精品一区二区三| 久久99精品久久久| 蜜臀av一级做a爰片久久| 日本va欧美va瓶| 久久国内精品视频| 日日夜夜一区二区| 免费国产亚洲视频| 裸体歌舞表演一区二区| 精品一区二区在线视频| 久国产精品韩国三级视频| 久久不见久久见免费视频1| 麻豆精品久久精品色综合| 久久国产福利国产秒拍| 青青草91视频| 精品无码三级在线观看视频| 国产精品一二三四| 成人小视频在线观看| 91蜜桃视频在线| 欧美年轻男男videosbes| 6080亚洲精品一区二区| 精品乱码亚洲一区二区不卡| 久久久五月婷婷| 日韩美女精品在线| 亚洲国产视频一区| 久久精品免费观看| www.亚洲色图.com| 国产精品丝袜一区| 一区免费观看视频| 性欧美疯狂xxxxbbbb| 麻豆成人av在线| 国产精品伊人色| 在线免费观看日本欧美| 欧美电影免费观看高清完整版在线| 久久久久国产一区二区三区四区| 国产精品久久福利| 丝袜美腿亚洲一区二区图片| 国产高清精品网站| 欧美三级视频在线观看| 久久综合九色综合97_久久久| 国产精品国产三级国产| 日本伊人精品一区二区三区观看方式| 国模套图日韩精品一区二区| 色94色欧美sute亚洲线路二 | 久久婷婷国产综合国色天香| 国产精品久久免费看| 天堂成人国产精品一区| 国产91精品在线观看| 在线成人av网站| 亚洲欧洲日产国码二区| 韩国午夜理伦三级不卡影院| 在线视频亚洲一区| 中文字幕国产一区| 久久精品国内一区二区三区| 9i看片成人免费高清| 精品久久久久久久久久久久久久久| 中文字幕亚洲在| 国产成人无遮挡在线视频| 欧美日韩一区在线观看|