"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/analysis_int.c" between
sip-0.5.6.tar.gz and sip-0.12.1.tar.gz

About: SIP (Scilab Image Processing) toolbox to do imaging tasks such as filtering, blurring, edge detection, thresholding, histogram manipulation, segmentation, mathematical morphology, color image processing, etc.

analysis_int.c  (sip-0.5.6):analysis_int.c  (sip-0.12.1)
skipping to change at line 213 skipping to change at line 213
ro=co=1; ro=co=1;
CreateVar(nv, "d", &ro, &co, &po); CreateVar(nv, "d", &ro, &co, &po);
*stk(po) = stat; *stk(po) = stat;
LhsVar(1) = nv; LhsVar(1) = nv;
return true; return true;
} }
/*---------------------------------------------------------------- /*----------------------------------------------------------------
* out = bwdist(img [,method, side]) * out = bwdist(img [,method, max_dist])
* Distance transforms. * Distance transforms.
* *
* "method" may be: * "method" may be:
* - "euclidean" : default euclidean method (Lotufo-Zampirolli) * - "euclidean" : default euclidean method (Lotufo-Zampirolli)
* - "lotufo-zampirolli" (fast exact euclidean) * - "lotufo-zampirolli" (fast exact euclidean)
* - "costa-estrozi" (exact euclidean) * - "costa-estrozi" (exact euclidean)
* - "IFT" - Image Foresting Transform (fast very accurate euclidean) * - "IFT" - Image Foresting Transform (fast very accurate euclidean)
* *
* In the future: * In the future:
* - "chessboard" * - "chessboard"
* - "chamfer" * - "chamfer"
* - (...) * - (...)
* *
* "side" may be:
* - "interior" (default)
* - "exterior"
* - "both"
*
* TODO * TODO
* - add an output Label parameter (discrete Voronoi diagram) * - add an output Label parameter (discrete Voronoi diagram)
*----------------------------------------------------------------*/ *----------------------------------------------------------------*/
SipExport int SipExport int
bwdist_int(char *fname) bwdist_int(char *fname)
{ {
int rim, cim, pim, // img int rim, cim, pim, // img
r_alg, c_alg, l_alg, r_alg, c_alg, l_alg,
r_side, c_side, l_side, r_d, c_d, l_d,
i, nv=1, i, nv=1,
minlhs=1, maxlhs=1, minrhs=1, maxrhs=2; minlhs=1, maxlhs=2, minrhs=1, maxrhs=4;
dt_algorithm alg=DT_MAURER2003; dt_algorithm alg=DT_MEIJSTER_2000;
double *pt; double *pt, *pt_lbl, max_dist = (double)((puint32) -1);
char *str; char *str;
bool noexec=false, stat, is1const; bool noexec=false, stat, is1const, use_label = false;
Img *im; Img *im;
ImgPUInt32 *dt; ImgPUInt32 *dt, *imlabel=NULL;
CheckRhs(minrhs,maxrhs); CheckLhs(minlhs,maxlhs); CheckRhs(minrhs,maxrhs); CheckLhs(minlhs,maxlhs);
if (Lhs >= 2) {
use_label = true;
if (Rhs == 1)
alg = DT_MAURER2003;
}
GetRhsVar(nv++, "d", &rim, &cim, &pim); // img GetRhsVar(nv++, "d", &rim, &cim, &pim); // img
if (Rhs == 2) { if (Rhs >= 2) {
GetRhsVar(nv++, "c", &r_alg, &c_alg, &l_alg); GetRhsVar(nv++, "c", &r_alg, &c_alg, &l_alg);
str=cstk(l_alg); str=cstk(l_alg);
if (strcasecmp("lotufo-zampirolli",str) == 0) if (strcasecmp("lotufo-zampirolli",str) == 0)
alg=DT_LOTUFO_ZAMPIROLLI; alg=DT_LOTUFO_ZAMPIROLLI;
else if ( strncasecmp("exact dilations",str,8) == 0 || else if ( strncasecmp("exact dilations",str,8) == 0 ||
/* backward-compat:*/ strcmp("costa-estrozi",str) == 0) /* backward-compat:*/ strcmp("costa-estrozi",str) == 0)
alg=DT_EXACT_DILATIONS; alg=DT_EXACT_DILATIONS;
else if ( strcasecmp("IFT",str) == 0 || else if ( strcasecmp("IFT",str) == 0 ||
strncasecmp("IFT 8",str,5) == 0) strncasecmp("IFT 8",str,5) == 0)
alg=DT_IFT; alg=DT_IFT;
skipping to change at line 286 skipping to change at line 287
alg=DT_CUISENAIRE_PMON_1999; alg=DT_CUISENAIRE_PMON_1999;
else if ( strncasecmp("cuisenaire psn4",str,15) == 0) else if ( strncasecmp("cuisenaire psn4",str,15) == 0)
alg=DT_CUISENAIRE_PSN4_1999; alg=DT_CUISENAIRE_PSN4_1999;
else if ( strncasecmp("cuisenaire psn8",str,15) == 0) else if ( strncasecmp("cuisenaire psn8",str,15) == 0)
alg=DT_CUISENAIRE_PSN8_1999; alg=DT_CUISENAIRE_PSN8_1999;
else if ( strncasecmp("noexec",str,5) == 0) else if ( strncasecmp("noexec",str,5) == 0)
noexec = true; noexec = true;
/* undocumented option used to see how much overhead does /* undocumented option used to see how much overhead does
* this interface function imposes for a particular image */ * this interface function imposes for a particular image */
else else
sip_error("invalid second argument -- unknown method"); sip_error("invalid second argument -- unknown or unimpl
} else if (Rhs == 3) { emented method");
GetRhsVar(nv++, "c", &r_side, &c_side, &l_side); if (Rhs >= 3) {
str=cstk(l_side); GetRhsVar(nv++, "d", &r_d, &c_d, &l_d);
sip_warning("There is no 3d argument ('side') anymore. The EDT is now only max_dist = *stk(l_d);
internal."); }
if (strncasecmp("external",str,3) == 0)
sip_error("To obtain an external EDT, simply negate the i if (use_label && alg!=DT_MAURER2003)
mage before calling bwdist.") sip_error("such algorithm choice does not currently support label");
else if (strncasecmp("both",str,3) == 0)
sip_error("To obtain an external and internal EDT, first
run bwborder on the image and pass its negative to bwdist.");
} }
// pass transposed image to internal row-wise storage // pass transposed image to internal row-wise storage
im=new_img(cim,rim); im = new_img(cim,rim);
sci_2D_double_matrix_to_animal(pim,rim,cim,im,pixval,1); sci_2D_double_matrix_to_animal(pim,rim,cim,im,pixval,1);
is1const=true; is1const=true;
for (i=0; i<rim*cim; ++i) for (i=0; i<rim*cim; ++i)
if (DATA(im)[i]==0) { if (DATA(im)[i]==0) {
is1const=false; is1const=false;
break; break;
} }
if (is1const) { if (is1const) {
sip_warning("the input image is constant and different than 0"); sip_warning("the input image is constant and different than 0");
sip_warning("the distance transform is undefined for this case"); sip_warning("the distance transform is undefined for this case");
} }
im->isbinary = true; im->isbinary = true;
if (noexec) if (noexec) {
dt = new_img_puint32(im->rows, im->cols); dt = new_img_puint32(im->rows, im->cols);
else if (use_label)
dt = distance_transform(im, alg); imlabel = new_img_puint32(cim,rim);
} else {
if (max_dist == (double)(puint32)-1) {
if (use_label) {
dt = distance_transform_label(im, alg, true, &imlabel);
} else
dt = distance_transform(im, alg);
} else {
if (use_label)
sip_error("label + max_dist not yet implemented.");
dt = distance_transform_max_dist(im, alg, max_dist*max_dist, false, &imla
bel);
}
}
if (!dt) sip_error("problem inside distance_transform C subroutine"); if (!dt) sip_error("problem inside distance_transform C subroutine");
if (use_label && !imlabel) sip_error("problem with label inside distance_tran
sform C subroutine");
imfree(&im); /* FIXME: use better err treatment */ imfree(&im); /* FIXME: use better err treatment */
stat = animal_grayscale_imgpuint32_to_double_array(fname,dt,&pt); stat = animal_grayscale_imgpuint32_to_double_array(fname,dt,&pt);
if (!stat) return false; if (!stat) return false;
imfree_puint32(&dt); imfree_puint32(&dt);
CreateVarFromPtr(nv, "d", &rim, &cim, &pt); CreateVarFromPtr(nv, "d", &rim, &cim, &pt);
LhsVar(1) = nv; LhsVar(1) = nv++;
free(pt); free(pt);
if (use_label) {
stat = animal_grayscale_imgpuint32_to_double_array(fname,imlabel,&pt_lbl);
if (!stat) return false;
imfree_puint32(&imlabel);
CreateVarFromPtr(nv, "d", &rim, &cim, &pt_lbl);
LhsVar(2) = nv++;
free(pt_lbl);
}
return true; return true;
} }
 End of changes. 17 change blocks. 
32 lines changed or deleted 55 lines changed or added

Home  |  About  |  All  |  Newest  |  Fossies Dox  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTPS