/* @description Returns the normalized black color of the pixel wand. */ value nMagick_pixel_get_black( value pixel ) { PixelWand *pix; val_check_kind( pixel, k_pixel ); pix = PIXEL( pixel ); return alloc_float( PixelGetBlack( pix ) ); }
/* {{{ proto float GmagickPixel::getColorValue(int color ) Gets the normalized color of the GmagickPixel. */ PHP_METHOD(gmagickpixel, getcolorvalue) { php_gmagickpixel_object *internp; zend_long color; double color_value = 0; /* Parse parameters given to function */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &color) == FAILURE) { return; } internp = Z_GMAGICKPIXEL_OBJ_P(getThis()); switch (color) { case GMAGICK_COLOR_BLACK: color_value = PixelGetBlack(internp->pixel_wand); break; case GMAGICK_COLOR_BLUE: color_value = PixelGetBlue(internp->pixel_wand); break; case GMAGICK_COLOR_CYAN: color_value = PixelGetCyan(internp->pixel_wand); break; case GMAGICK_COLOR_GREEN: color_value = PixelGetGreen(internp->pixel_wand); break; case GMAGICK_COLOR_RED: color_value = PixelGetRed(internp->pixel_wand); break; case GMAGICK_COLOR_YELLOW: color_value = PixelGetYellow(internp->pixel_wand); break; case GMAGICK_COLOR_MAGENTA: color_value = PixelGetMagenta(internp->pixel_wand); break; case GMAGICK_COLOR_OPACITY: color_value = PixelGetOpacity(internp->pixel_wand); break; default: GMAGICK_THROW_GMAGICKPIXEL_EXCEPTION(internp->pixel_wand, "Unknown color type"); break; } RETVAL_DOUBLE(color_value); }
/** * Extracts from a binary image white points and consider them as information * filling sample array and setting size structure. * * NOTE: When extracting points origin is moved to the center of the image: * * +semi_height * Image Origin * +-----------| * | | * | | * | | Hough Origin * -semi_width ------------+------------- +semi_width * | * | * | * | * * -semi_height */ sizep_t get_points(char* name, POINT_TYPE **sample, SIZE_TYPE *size) { MagickWand *mw = NULL; PixelWand **pmw = NULL; PixelIterator *imw = NULL; MagickWandGenesis(); mw = NewMagickWand(); MagickReadImage(mw, name); unsigned long width, semi_width, height, semi_height; width = MagickGetImageWidth(mw); semi_width = ceil(width/2.0); height = MagickGetImageHeight(mw); semi_height = ceil(height/2.0); imw = NewPixelIterator(mw); sizep_t count = 0; POINT_TYPE *aux = (POINT_TYPE*) malloc(sizeof(POINT_TYPE)*width*height); // Extract white points int y, x; for (y=0; y<height; y++) { pmw = PixelGetNextIteratorRow(imw, &width); for (x=0; x< (long) width; x++) { if (PixelGetBlack(pmw[x])) { aux[count].x = x-semi_width; aux[count].y = (height-y)-semi_height; count++; } } } POINT_TYPE* output = (POINT_TYPE*) malloc(sizeof(POINT_TYPE)*count); memcpy(output, aux, sizeof(POINT_TYPE)*count); free(aux); aux = NULL; if(mw) mw = DestroyMagickWand(mw); MagickWandTerminus(); (*sample) = output; size->width = width; size->height = height; return count; }
/* {{{ proto float ImagickPixel::getColorValue(int color) Gets the normalized value of a color in the ImagickPixel. */ PHP_METHOD(imagickpixel, getcolorvalue) { php_imagick_color_t color_enum; php_imagickpixel_object *internp; im_long color; double color_value = 0; /* Parse parameters given to function */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &color) == FAILURE) { return; } internp = Z_IMAGICKPIXEL_P(getThis()); if (color <= PHP_IMAGICK_COLOR_MIN || color >= PHP_IMAGICK_COLOR_MAX) { php_imagick_throw_exception (IMAGICKPIXEL_CLASS, "Unknown color type" TSRMLS_CC); return; } color_enum = color; switch (color_enum) { case PHP_IMAGICK_COLOR_BLACK: color_value = PixelGetBlack(internp->pixel_wand); break; case PHP_IMAGICK_COLOR_BLUE: color_value = PixelGetBlue(internp->pixel_wand); break; case PHP_IMAGICK_COLOR_CYAN: color_value = PixelGetCyan(internp->pixel_wand); break; case PHP_IMAGICK_COLOR_GREEN: color_value = PixelGetGreen(internp->pixel_wand); break; case PHP_IMAGICK_COLOR_RED: color_value = PixelGetRed(internp->pixel_wand); break; case PHP_IMAGICK_COLOR_YELLOW: color_value = PixelGetYellow(internp->pixel_wand); break; case PHP_IMAGICK_COLOR_MAGENTA: color_value = PixelGetMagenta(internp->pixel_wand); break; #if MagickLibVersion < 0x700 case PHP_IMAGICK_COLOR_OPACITY: color_value = PixelGetOpacity(internp->pixel_wand); break; #endif case PHP_IMAGICK_COLOR_ALPHA: color_value = PixelGetAlpha(internp->pixel_wand); break; #if MagickLibVersion > 0x628 case PHP_IMAGICK_COLOR_FUZZ: color_value = PixelGetFuzz(internp->pixel_wand); break; #endif default: php_imagick_throw_exception (IMAGICKPIXEL_CLASS, "Unknown color type" TSRMLS_CC); return; break; } RETVAL_DOUBLE(color_value); }
/* {{{ proto float ImagickPixel::getColorValue(int color) Gets the normalized color of the ImagickPixel. */ PHP_METHOD(imagickpixel, getcolorvalue) { php_imagickpixel_object *internp; long color; double color_value = 0; /* Parse parameters given to function */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &color) == FAILURE) { return; } internp = (php_imagickpixel_object *)zend_object_store_get_object(getThis() TSRMLS_CC); switch (color) { case IMAGICKCOLORBLACK: color_value = PixelGetBlack(internp->pixel_wand); break; case IMAGICKCOLORBLUE: color_value = PixelGetBlue(internp->pixel_wand); break; case IMAGICKCOLORCYAN: color_value = PixelGetCyan(internp->pixel_wand); break; case IMAGICKCOLORGREEN: color_value = PixelGetGreen(internp->pixel_wand); break; case IMAGICKCOLORRED: color_value = PixelGetRed(internp->pixel_wand); break; case IMAGICKCOLORYELLOW: color_value = PixelGetYellow(internp->pixel_wand); break; case IMAGICKCOLORMAGENTA: color_value = PixelGetMagenta(internp->pixel_wand); break; case IMAGICKCOLOROPACITY: color_value = PixelGetOpacity(internp->pixel_wand); break; case IMAGICKCOLORALPHA: color_value = PixelGetAlpha(internp->pixel_wand); break; #if MagickLibVersion > 0x628 case IMAGICKCOLORFUZZ: color_value = PixelGetFuzz(internp->pixel_wand); break; #endif default: php_imagick_throw_exception (IMAGICKPIXEL_CLASS, "Unknown color type" TSRMLS_CC); return; break; } RETVAL_DOUBLE(color_value); }