int convert (MagickWand *input, MagickWand **output, convert_t *opts, unsigned char* data, size_t size) { if (convert_density(input, opts) != MagickPass) return -7; if (MagickReadImageBlob(input, data, size) != MagickPass) return -2; if (convert_adjoin(input, output, opts) != MagickPass) return -8; input = *output; MagickResetIterator(input); MagickNextImage(input); // Has to be called after MagickResetIterator to set the first picture as the current do { if (convert_format(input, opts) != MagickPass) return -3; if (convert_scale(input, opts) != MagickPass) return -4; if (convert_rotate(input, opts) != MagickPass) return -5; if (convert_crop(input, opts) != MagickPass) return -6; } while (MagickNextImage(input)); return 0; }
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { register int i; float x; int max_len = 6; int p; int ns0 = 29; static area_function *af0; if (CheckArguments(nlhs, plhs, nrhs, prhs) ){ mexErrMsgTxt("AMgetdata argument checking failed."); return ; } /* read nasal tract area function from the file */ //printf("Reading nasal tract file.\n"); read_af(NTAFpath , &nna, &afnt ); //printf("Finished Reading nasal tract file.\n"); /* Initialization */ //read_rad(); // update all constants and variables if((int)(pTCcfg[0]) == RL_CIRCUIT) rad_boundary = RL_CIRCUIT; else rad_boundary = SHORT_CIRCUIT; //printf("Rad_boundary[%d]\n",rad_boundary); if((int)(pTCcfg[1]) == YIELDING) wall = YIELDING; else wall = RIGID; //printf("wall[%d]\n",wall); if((int)(pTCcfg[2]) == ON) nasal_tract = ON; else nasal_tract = OFF; //printf("nasal_tract[%d]\n",nasal_tract); if((int)(pTCcfg[3]) == CLOSE) glt_boundary = CLOSE; else glt_boundary = OPEN; //printf("glt_boundary[%d]\n",glt_boundary); ro = (float)(pPCcfg[0]); //printf("Air density[%f]\n",ro); c = (float)(pPCcfg[1]); //printf("Sound velocity[%f]\n",c); wall_resi = (float)(pPCcfg[2]); //printf("wall_resi[%f]\n",wall_resi); wall_mass = (float)(pPCcfg[3]); //printf("wall_mass[%f]\n",wall_mass); wall_comp = (float)(pPCcfg[4]); //printf("wall_comp[%f]\n",wall_comp); for(i=0;i<7;i++) { AMpar[i] = (float)(pAMcfg[i]); //printf("AMpar[%d][%f]\n",i,AMpar[i]); } anc = (float)(pAMcfg[7]); //printf("nasal area[%f]\n",anc); /* Initialization */ read_model_spec(); af0 = (area_function *) calloc( ns0, sizeof(area_function) ); nph = 9; nbu = 8; nss = nbu + nph; afvt = (area_function *) calloc( nss, sizeof(area_function) ); convert_scale(); semi_polar(); oAf = mxCreateDoubleMatrix(2,nss, mxREAL); pAf = mxGetPr(oAf); /* Compute VT profile and area function, and plot them */ lam( AMpar ); /* profile */ sagittal_to_area( &ns0, af0 ); /* area function */ for(i=0;i<ns0;i++) { //printf("AreaNS0[%d][%f]\n",i,af0[i]); } appro_area_function( ns0, af0, nss, afvt); for(i=0;i<nss;i++) { //printf("AreaAF[%d][%f]\n",i,afvt[i]); pAf[2*i] = afvt[i].A; pAf[2*i+1] = afvt[i].x; } if( nasal_tract == ON ) { anc = (float) min( anc, afvt[nph].A ); afvt[nph].A -= anc; pAf[2*nph] = afvt[nph].A; pAf[2*nph+1] = afvt[nph].x; } calplot_tf_FBA(nfrmmax, frm, bw, amp, &nfrms, tfunc, &ntf); //printf("Finished calculations.\n"); oPdat1 = mxCreateDoubleMatrix(4,NP, mxREAL); pPdat1 = mxGetPr(oPdat1); for(i=0;i<NP;i++) { pPdat1[4*i] = ivt[i].x; pPdat1[4*i+1] = ivt[i].y; pPdat1[4*i+2] = evt[i].x; pPdat1[4*i+3] = evt[i].y; } oPdat2 = mxCreateDoubleMatrix(1,2,mxREAL); pPdat2 = mxGetPr(oPdat2); pPdat2[0] = lip_w; pPdat2[1] = lip_h; oTf = mxCreateDoubleMatrix(ntf, 1, mxREAL); pTf = mxGetPr(oTf); for(i=0;i<ntf;i++) { pTf[i] = tfunc[i]; } oFmt = mxCreateDoubleMatrix(nfrms, 1, mxREAL); pFmt = mxGetPr(oFmt); oBw = mxCreateDoubleMatrix(nfrms, 1, mxREAL); pBw = mxGetPr(oBw); oAmp = mxCreateDoubleMatrix(nfrms, 1, mxREAL); pAmp = mxGetPr(oAmp); for(i=0;i<nfrms;i++) { pFmt[i] = frm[i]; pBw[i] = bw[i]; pAmp[i] = amp[i]; } /* Assign output pointers */ plhs[0] = oAf; plhs[1] = oTf; plhs[2] = oFmt; plhs[3] = oBw; plhs[4] = oAmp; plhs[5] = oPdat1; plhs[6] = oPdat2; // do cleanup //free( rad_re ); //free( rad_im ); free( afnt ); free( af0 ); free( afvt ); }
void CVTract::SetSize(double size) { int nfs, nafs; /* semi-polar coordinate specs. */ // skiplines( in, 9 ); //fscanf(in, "%d %d %d %f %f %f %d %d\n", // &m1, &m2, &m3, &dl, &omega, &theta, &ix0, &iy0 ); m1 = 14; m2 = 11; m3 = 6; dl = 0.50000; omega = -11.25000; theta = 11.25000; ix0 = 3000; iy0 = 1850; //skiplines( in, 1 ); //fscanf(in, "%f %f \n", &TEKvt, &TEKlip); TEKvt = 188.679245; TEKlip = 0.000000; //skiplines( in, 1 ); //for(i=0; i<m1+m2+m3; i++) // fscanf(in, "%d %f %f \n", &dummy, &alph[i], &beta[i]); alph[0] = 1.800000; beta[0] = 1.200000; alph[1] = 1.800000; beta[1] = 1.200000; alph[2] = 1.800000; beta[2] = 1.200000; alph[3] = 1.800000; beta[3] = 1.200000; alph[4] = 1.800000; beta[4] = 1.200000; alph[5] = 1.800000; beta[5] = 1.200000; alph[6] = 1.800000; beta[6] = 1.200000; alph[7] = 1.800000; beta[7] = 1.200000; alph[8] = 1.800000; beta[8] = 1.200000; alph[9] = 1.800000; beta[9] = 1.200000; alph[10] = 1.800000; beta[10] = 1.200000; alph[11] = 1.800000; beta[11] = 1.200000; alph[12] = 1.800000; beta[12] = 1.200000; alph[13] = 1.800000; beta[13] = 1.200000; alph[14] = 1.800000; beta[14] = 1.200000; alph[15] = 1.800000; beta[15] = 1.200000; alph[16] = 1.800000; beta[16] = 1.300000; alph[17] = 1.700000; beta[17] = 1.400000; alph[18] = 1.700000; beta[18] = 1.400000; alph[19] = 1.700000; beta[19] = 1.500000; alph[20] = 1.700000; beta[20] = 1.500000; alph[21] = 1.700000; beta[21] = 1.500000; alph[22] = 1.700000; beta[22] = 1.500000; alph[23] = 1.700000; beta[23] = 1.500000; alph[24] = 1.700000; beta[24] = 1.500000; alph[25] = 1.700000; beta[25] = 1.500000; alph[26] = 1.800000; beta[26] = 1.500000; alph[27] = 1.800000; beta[27] = 1.500000; alph[28] = 1.900000; beta[28] = 1.500000; alph[29] = 2.000000; beta[29] = 1.500000; alph[30] = 2.600000; beta[30] = 1.500000; /* Lip specifications */ //skiplines( in, 2 ); //fscanf(in, "%d %d %d %d %d %d\n", // &nvrs_lip, &jaw_lip, &dummy, &dummy, &nfs, &nafs); nvrs_lip = 4; jaw_lip = 1; nfs = 4; nafs = 2; //if( jaw_lip != JAW || nfs < JAW+LIP ) //{ printf("Not enough factors in the lip spec.."); // exit(1); //} //skiplines( in, nafs + 2 ); //for(i=0; i<nvrs_lip; i++) fscanf(in, "%s\n", vlab_dummy); //skiplines( in, 1 ); //for(i=0; i<JAW+LIP; i++) fscanf(in, "%s\n", flab_lip[i]); strcpy(flab_lip[0],"JW"); strcpy(flab_lip[1],"HT"); strcpy(flab_lip[2],"P1"); //skiplines( in, 2 ); //for(i=0; i<nvrs_lip; i++) fscanf(in, "%f \n", &u_lip[i]); u_lip[0] = 104.271675; u_lip[1] = 122.812141; u_lip[2] = 135.938339; u_lip[3] = 460.440857; //skiplines( in, 1 ); //for(i=0; i<nvrs_lip; i++) fscanf(in, "%f \n", &s_lip[i]); s_lip[0] = 27.674635; s_lip[1] = 33.068081; s_lip[2] = 99.392258; s_lip[3] = 213.996170; //skiplines( in, 1 ); //fscanf(in, "%f %f \n", &inci_x, &inci_y); inci_x = 2212.354492; inci_y = 1999.574219; //skiplines( in, 3 ); //for(i=0; i<nvrs_lip; i++) //{ for(j=0; j<JAW+LIP; j++) fscanf(in, "%f \n", &A_lip[i][j]); // skiplines( in, 1 ); //} A_lip[0][0] = 1.000000; A_lip[0][1] = 0.000000; A_lip[0][2] = 0.000000; A_lip[1][0] = 0.178244; A_lip[1][1] =-0.395733; A_lip[1][2] = 0.888897; A_lip[2][0] =-0.154638; A_lip[2][1] = 0.987971; A_lip[2][2] = 0.000000; A_lip[3][0] =-0.217332; A_lip[3][1] = 0.825187; A_lip[3][2] =-0.303429; //skiplines( in, 1 + nvrs_lip ); /* Tongue */ //skiplines( in, 2 ); //fscanf(in, "%d %d %d %d %d %d\n", // &nvrs_tng, &jaw_tng, &iniva_tng, &lstva_tng, &nfs, &nafs); nvrs_tng = 26; jaw_tng = 1; iniva_tng = 7; lstva_tng = 31; nfs = 7; nafs = 1; //if( jaw_tng != JAW || nfs < JAW+TNG ) //{ printf("Not enough factors in the tongue spec.."); // exit(1); //} iniva_tng--; /* coordinate address for C, now same as lable */ lstva_tng--; //skiplines( in, nafs + 2 ); //for(i=0; i<nvrs_tng; i++) fscanf(in, "%s\n", vlab_dummy); //skiplines( in, 1 ); //for(i=0; i<JAW+TNG; i++) fscanf(in, "%s\n", flab_tng[i]); strcpy(flab_tng[0],"JW"); strcpy(flab_tng[1],"P1"); strcpy(flab_tng[2],"P2"); strcpy(flab_tng[3],"P3"); //skiplines( in, 2 ); //for(i=0; i<nvrs_tng; i++) fscanf(in, "%f \n", &u_tng[i]); u_tng[0] = 104.271675; u_tng[1] = 443.988434; u_tng[2] = 450.481689; u_tng[3] = 399.942200; u_tng[4] = 348.603088; u_tng[5] = 351.181122; u_tng[6] = 365.404633; u_tng[7] = 370.290955; u_tng[8] = 356.202301; u_tng[9] = 341.890167; u_tng[10] = 332.117523; u_tng[11] = 326.826599; u_tng[12] = 326.512512; u_tng[13] = 331.631989; u_tng[14] = 343.175323; u_tng[15] = 361.265900; u_tng[16] = 385.231201; u_tng[17] = 411.826599; u_tng[18] = 435.691711; u_tng[19] = 455.040466; u_tng[20] = 462.736023; u_tng[21] = 453.025055; u_tng[22] = 432.250488; u_tng[23] = 407.358368; u_tng[24] = 384.551056; u_tng[25] = 363.836212; //skiplines( in, 1 ); //for(i=0; i<nvrs_tng; i++) fscanf(in, "%f \n", &s_tng[i]); //s_tng[0] = 27.674635; s_tng[1] = 29.947931; s_tng[2] = 44.694466; s_tng[3] = 99.310226; s_tng[4] = 96.871323; s_tng[5] = 84.140404; s_tng[6] = 78.357513; s_tng[7] = 73.387718; s_tng[8] = 72.926758; s_tng[9] = 71.453232; s_tng[10] = 69.288765; s_tng[11] = 66.615509; s_tng[12] = 63.603722; s_tng[13] = 59.964859; s_tng[14] = 56.695446; s_tng[15] = 56.415058; s_tng[16] = 62.016468; s_tng[17] = 73.235176; s_tng[18] = 84.008438; s_tng[19] = 91.488312; s_tng[20] = 94.124176; s_tng[21] = 95.246323; s_tng[22] = 93.516365; s_tng[23] = 93.000343; s_tng[24] = 100.934669; s_tng[25] = 106.512482; //skiplines( in, 1 ); //for(i=0; i<nvrs_tng; i++) //{ for(j=0; j<JAW+TNG; j++) fscanf(in, "%f \n", &A_tng[i][j]); // skiplines( in, 1 ); //} A_tng[0][0] = 1.000000; A_tng[0][1] = 0.000000; A_tng[0][2] = 0.000000; A_tng[0][3] = 0.000000; A_tng[1][0] =-0.464047; A_tng[1][1] = 0.098776; A_tng[1][2] =-0.251690; A_tng[1][3] = 0.228351; A_tng[2][0] =-0.328015; A_tng[2][1] = 0.337579; A_tng[2][2] =-0.283667; A_tng[2][3] = 0.568234; A_tng[3][0] =-0.213039; A_tng[3][1] = 0.485565; A_tng[3][2] =-0.283533; A_tng[3][3] = 0.653696; A_tng[4][0] =-0.302565; A_tng[4][1] = 0.705432; A_tng[4][2] =-0.379044; A_tng[4][3] = 0.392917; A_tng[5][0] =-0.327806; A_tng[5][1] = 0.786897; A_tng[5][2] =-0.388116; A_tng[5][3] = 0.245703; A_tng[6][0] =-0.325065; A_tng[6][1] = 0.852409; A_tng[6][2] =-0.285125; A_tng[6][3] = 0.176843; A_tng[7][0] =-0.325739; A_tng[7][1] = 0.904725; A_tng[7][2] =-0.142602; A_tng[7][3] = 0.138558; A_tng[8][0] =-0.313741; A_tng[8][1] = 0.926339; A_tng[8][2] = 0.021042; A_tng[8][3] = 0.122976; A_tng[9][0] =-0.288138; A_tng[9][1] = 0.924019; A_tng[9][2] = 0.131949; A_tng[9][3] = 0.116762; A_tng[10][0] =-0.249008; A_tng[10][1] = 0.909585; A_tng[10][2] = 0.250320; A_tng[10][3] = 0.112433; A_tng[11][0] =-0.196936; A_tng[11][1] = 0.882236; A_tng[11][2] = 0.369083; A_tng[11][3] = 0.112396; A_tng[12][0] =-0.128884; A_tng[12][1] = 0.830243; A_tng[12][2] = 0.499894; A_tng[12][3] = 0.115700; A_tng[13][0] =-0.040825; A_tng[13][1] = 0.730520; A_tng[13][2] = 0.651662; A_tng[13][3] = 0.112048; A_tng[14][0] = 0.073420; A_tng[14][1] = 0.543080; A_tng[14][2] = 0.807947; A_tng[14][3] = 0.126204; A_tng[15][0] = 0.202726; A_tng[15][1] = 0.230555; A_tng[15][2] = 0.919065; A_tng[15][3] = 0.163735; A_tng[16][0] = 0.298853; A_tng[16][1] =-0.162541; A_tng[16][2] = 0.899074; A_tng[16][3] = 0.213884; A_tng[17][0] = 0.332785; A_tng[17][1] =-0.491647; A_tng[17][2] = 0.748869; A_tng[17][3] = 0.243163; A_tng[18][0] = 0.349955; A_tng[18][1] =-0.681313; A_tng[18][2] = 0.567615; A_tng[18][3] = 0.245295; A_tng[19][0] = 0.377277; A_tng[19][1] =-0.771200; A_tng[19][2] = 0.410502; A_tng[19][3] = 0.249425; A_tng[20][0] = 0.422713; A_tng[20][1] =-0.804874; A_tng[20][2] = 0.270513; A_tng[20][3] = 0.274015; A_tng[21][0] = 0.474635; A_tng[21][1] =-0.797704; A_tng[21][2] = 0.129324; A_tng[21][3] = 0.314454; A_tng[22][0] = 0.526087; A_tng[22][1] =-0.746938; A_tng[22][2] =-0.026201; A_tng[22][3] = 0.366149; A_tng[23][0] = 0.549466; A_tng[23][1] =-0.643572; A_tng[23][2] =-0.190005; A_tng[23][3] = 0.422848; A_tng[24][0] = 0.494200; A_tng[24][1] =-0.504012; A_tng[24][2] =-0.350434; A_tng[24][3] = 0.488056; A_tng[25][0] = 0.448797; A_tng[25][1] =-0.417352; A_tng[25][2] =-0.445410; A_tng[25][3] = 0.500909; //skiplines( in, 1 + nvrs_tng ); /* Larynx */ //skiplines( in, 2 ); //fscanf(in, "%d %d %d %d %d %d\n", // &nvrs_lrx, &jaw_lrx, &iniva_lrx, &lstva_lrx, &nfs, &nafs); nvrs_lrx = 5; jaw_lrx = 1; iniva_lrx = 7; lstva_lrx = 6; nfs = 5; nafs = 2; //if( jaw_lrx != JAW || nfs < JAW+LRX ) //{ printf("No enough factors in the larynx spec.."); // exit(1); //} //skiplines( in, nafs + 2 ); //for(i=0; i<nvrs_lrx; i++) fscanf(in, "%s\n", vlab_dummy); //skiplines( in, 1 ); //for(i=0; i<JAW+LRX; i++) fscanf(in, "%s\n", flab_lrx[i]); strcpy(flab_lrx[0],"JW"); strcpy(flab_lrx[1],"Y1"); //skiplines( in, 2 ); //for(i=0; i<nvrs_lrx; i++) fscanf(in, "%f \n", &u_lrx[i]); u_lrx[0] = 104.271675; u_lrx[1] = 143.138733; u_lrx[2] = -948.229309; u_lrx[3] = 404.678223; u_lrx[4] = -962.936401; //skiplines( in, 1 ); //for(i=0; i<nvrs_lrx; i++) fscanf(in, "%f \n", &s_lrx[i]); s_lrx[0] = 27.674635; s_lrx[1] = 41.593315; s_lrx[2] = 65.562340; s_lrx[3] = 44.372742; s_lrx[4] = 66.147499; //skiplines( in, 1 ); //for(i=0; i<nvrs_lrx; i++) //{ for(j=0; j<JAW+LRX; j++) fscanf(in, "%f \n", &A_lrx[i][j]); // skiplines( in, 1 ); //} A_lrx[0][0] = 1.000000; A_lrx[0][1] = 0.000000; A_lrx[1][0] =-0.208338; A_lrx[1][1] = 0.262446; A_lrx[2][0] = 0.127814; A_lrx[2][1] = 0.991798; A_lrx[3][0] =-0.131840; A_lrx[3][1] = 0.300784; A_lrx[4][0] = 0.097688; A_lrx[4][1] = 0.934267; //skiplines( in, 1 + nvrs_lrx ); /* Wall */ //skiplines( in, 2 ); //fscanf(in, "%d %d %d %d %d %d\n", //&nvrs_wal, &jaw_wal, &iniva_wal, &lstva_wal, &nfs, &nafs); nvrs_wal = 25; jaw_wal = 0; iniva_wal = 7; lstva_wal = 31; nfs = 7; nafs = 0; iniva_wal--; /* coordinate address for C, now same as lable */ lstva_wal--; //skiplines( in, nafs + 2 ); //for(i=0; i<nvrs_wal; i++) fscanf(in, "%s\n", vlab_dummy); //skiplines( in, 3 ); //for(i=0; i<nvrs_wal; i++) fscanf(in, "%f \n", &u_wal[i]); u_wal[0] = 550.196533; u_wal[1] = 604.878601; u_wal[2] = 674.127197; u_wal[3] = 678.776489; u_wal[4] = 665.905579; u_wal[5] = 653.312134; u_wal[6] = 643.223511; u_wal[7] = 633.836243; u_wal[8] = 636.994202; u_wal[9] = 668.834290; u_wal[10] = 703.098267; u_wal[11] = 657.815002; u_wal[12] = 649.919067; u_wal[13] = 565.194580; u_wal[14] = 529.824646; u_wal[15] = 573.250488; u_wal[16] = 603.023132; u_wal[17] = 621.433533; u_wal[18] = 643.055847; u_wal[19] = 650.136780; u_wal[20] = 630.809265; u_wal[21] = 589.867065; u_wal[22] = 556.134888; u_wal[23] = 541.551086; u_wal[24] = 525.210022; // other initialisation vp_map = 1.0f; size_correction = 1.10f; vp_width_cm = 10.0f; inci_lip = 0.8f; inci_lip_vp = 0; size_correction = size; vp_width_cm = 1.1 * 10.0 / size; convert_scale(); semi_polar(); }