Git Product home page Git Product logo

Comments (1)

Danack avatar Danack commented on July 19, 2024

Thanks for pointing me in the right direction, and apologies for the slow response.

It seems like this value is only available some of the time....I guess maybe only when the ImagickPixel is returned out of a getImageHistogram?

For the code below, getting a pixel through $imagick->getImagePixelColor(50, 50); it seems that the ImagickPixel has a count of zero associated with it. But then getting all of the colors through the histogram function, you can see that the last entry of the histogram, which has the same white color as the pixel retrieved through getImagePixelColor, instead has a count of 256244 associated with it.


color count is 0

r 1.000000 g 1.000000 b 1.000000 array(4) {
  ["r"]=>
  int(255)
  ["g"]=>
  int(255)
  ["b"]=>
  int(255)
  ["a"]=>
  int(1)
}
count: 256244

...
... 254 more entries here.
...



r 1.000000 g 1.000000 b 1.000000 array(4) {
  ["r"]=>
  int(255)
  ["g"]=>
  int(255)
  ["b"]=>
  int(255)
  ["a"]=>
  int(1)
}
count: 256244


$imagick = new Imagick();
$imagick->newPseudoImage(640, 480, "magick:logo");
$imagickPixel = $imagick->getImagePixelColor(50, 50);
$count = $imagickPixel->getColorCount();

echo "color count is ".$imagickPixel->getColorCount().PHP_EOL;


$histogramElements = $imagick->getImageHistogram();
echo "There are ".count($histogramElements)." elements in the histogram.".PHP_EOL;

/** @var $histogramElements ImagickPixel[] */
foreach ($histogramElements as $histogramElement) {
    $count = $histogramElement->getColorCount();

    printf(
        "r %f g %f b %f ",
        $histogramElement->getColorValue(\Imagick::COLOR_RED),
        $histogramElement->getColorValue(\Imagick::COLOR_GREEN),
        $histogramElement->getColorValue(\Imagick::COLOR_BLUE)
    );

    var_dump($histogramElement->getColor());

    echo "count: ".$count.PHP_EOL;
}

from imagickdemos.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.