Imagick::getImageChannelRange

(PECL imagick 2 >= 2.2.1, PECL imagick 3)

Imagick::getImageChannelRange β€” Π’ΠΎΠ·Π²Ρ€Π°Ρ‰Π°Π΅Ρ‚ Π΄ΠΈΠ°ΠΏΠ°Π·ΠΎΠ½ ΠΊΠ°Π½Π°Π»ΠΎΠ²

ОписаниС

public function Imagick::getImageChannelRange(int $channel): array

Π’ΠΎΠ·Π²Ρ€Π°Ρ‰Π°Π΅Ρ‚ Π΄ΠΈΠ°ΠΏΠ°Π·ΠΎΠ½ для ΠΎΠ΄Π½ΠΎΠ³ΠΎ ΠΈΠ»ΠΈ Π½Π΅ΡΠΊΠΎΠ»ΡŒΠΊΠΈΡ… ΠΊΠ°Π½Π°Π»ΠΎΠ² изобраТСния. ΠœΠ΅Ρ‚ΠΎΠ΄ доступСн, Ссли ΠΌΠΎΠ΄ΡƒΠ»ΡŒ Imagick скомпилировали с вСрсиСй ImageMagick 6.4.0 ΠΈΠ»ΠΈ ΡΡ‚Π°Ρ€ΡˆΠ΅.

Бписок ΠΏΠ°Ρ€Π°ΠΌΠ΅Ρ‚Ρ€ΠΎΠ²

channel

ΠŸΠ΅Ρ€Π΅Π΄Π°ΠΉΡ‚Π΅ Π»ΡŽΠ±ΡƒΡŽ ΠΊΠΎΡ€Ρ€Π΅ΠΊΡ‚Π½ΡƒΡŽ для вашСго Ρ€Π΅ΠΆΠΈΠΌΠ° ΠΊΠ°Π½Π°Π»Π° константу. Для примСнСния ΠΊ Π±ΠΎΠ»Π΅Π΅ Ρ‡Π΅ΠΌ ΠΎΠ΄Π½ΠΎΠΌΡƒ ΠΊΠ°Π½Π°Π»Ρƒ, ΠΊΠΎΠΌΠ±ΠΈΠ½ΠΈΡ€ΡƒΠΉΡ‚Π΅ константы ΠΊΠ°Π½Π°Π»ΠΎΠ² с ΠΏΠΎΠΌΠΎΡ‰ΡŒΡŽ ΠΏΠΎΠ±ΠΈΡ‚ΠΎΠ²Ρ‹Ρ… ΠΎΠΏΠ΅Ρ€Π°Ρ‚ΠΎΡ€ΠΎΠ². По ΡƒΠΌΠΎΠ»Ρ‡Π°Π½ΠΈΡŽ Ρ€Π°Π²Π½ΠΎ Imagick::CHANNEL_DEFAULT. ΠžΠ±Ρ€Π°Ρ‚ΠΈΡ‚Π΅ΡΡŒ ΠΊ списку констант ΠΊΠ°Π½Π°Π»ΠΎΠ²

Π’ΠΎΠ·Π²Ρ€Π°Ρ‰Π°Π΅ΠΌΡ‹Π΅ значСния

Π’ΠΎΠ·Π²Ρ€Π°Ρ‰Π°Π΅Ρ‚ массив, содСрТащий ΠΌΠΈΠ½ΠΈΠΌΠ°Π»ΡŒΠ½Ρ‹Π΅ ΠΈ ΠΌΠ°ΠΊΡΠΈΠΌΠ°Π»ΡŒΠ½Ρ‹Π΅ значСния ΠΊΠ°Π½Π°Π»Π°(ΠΎΠ²).

Ошибки

Ѐункция выбрасываСт ΠΈΡΠΊΠ»ΡŽΡ‡Π΅Π½ΠΈΠ΅ ImagickException, Ссли Π²ΠΎΠ·Π½ΠΈΠΊΠ»Π° ошибка.

οΌ‹Π”ΠΎΠ±Π°Π²ΠΈΡ‚ΡŒ

ΠŸΡ€ΠΈΠΌΠ΅Ρ‡Π°Π½ΠΈΡ ΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚Π΅Π»Π΅ΠΉ 1 note

up
0
holdoffhunger at gmail dot com ΒΆ
14 years ago
The getImageChannelRange returns an array with two values mapped to the keys 'minima' and 'maxima', which are simply the minimum and maximum values of that particular channel within the image that this function is performed upon.  For photographs and high-quality imagery, that means that you're almost always guaranteed to have the minima be at 0 and the maxima be at the maximum bit-value allowed.  For most images, that's 65,535, which is the value of 2^16 (if you start counting at 0), meaning 16-bits per Channel imagery.  This goes for all of the channels.

If an image is simple, though, you may be able to get a better variety of ranges.  An image that was simply a red square, the maxima and minima values for the Red Channel were both 65,535 (max), while the channels for the maxima and minima values for all other channels was 0 (min).  If you want to know the maximum values you might get back for any of the channels, feed this function the default channel.

For your normal channels, you'll have something that looks like "imagick::CHANNEL_RED", but you could have unusual channels like "imagick::CHANNEL_OPACITY".  For colors, you have the "_VALUE" options of: red, gray, cyan, green, magenta, blue, yellow, all, and default.  For unusual channels, you have the "_VALUE" options of: undefined, alpha, opacity, matte, black, and index.  With this function, the unusual channels always produce a minima of 1.0E+37 (10^37) and a maxima of -1.0E-37 (-10^-37), which makes no sense, so stick to the color values I pointed to above.

This function doesn't work for you?  No problem.  The function getImageChannelExtrema does the same *EXACT* thing.  The only difference is that the error you get on the unusual channels: their minima and maxima, instead of defaulting to crazy values, simply defaults to 0.

In general, this function seems to have the utility of telling you how simple an image might be -- if the difference between a channel maxima and minima is very small, that means there wasn't much expression of color for that given channel.  This will probably be able to tell you whether an image was drawn in some simple paint program or if it's an actual photograph, but beyond that, you'll have to do intensive programming to make it figure something out more complicated.

And now, an example of the results for some red-only image:

ImageMagick - Channel Range
Channel - 'Undefined' :     Minima: 1.0E+37     Maxima: -1.0E-37
Channel - 'Red' :     Minima: 65535     Maxima: 65535
Channel - 'Gray' :     Minima: 65535     Maxima: 65535
Channel - 'Cyan' :     Minima: 65535     Maxima: 65535
Channel - 'Green' :     Minima: 0     Maxima: 0
Channel - 'Magenta' :     Minima: 0     Maxima: 0
Channel - 'Blue' :     Minima: 0     Maxima: 0
Channel - 'Yellow' :     Minima: 0     Maxima: 0
Channel - 'Alpha' :     Minima: 1.0E+37     Maxima: -1.0E-37
Channel - 'Opacity' :     Minima: 1.0E+37     Maxima: -1.0E-37
Channel - 'Matte' :     Minima: 1.0E+37     Maxima: -1.0E-37
Channel - 'Black' :     Minima: 1.0E+37     Maxima: -1.0E-37
Channel - 'Index' :     Minima: 1.0E+37     Maxima: -1.0E-37
Channel - 'All' :     Minima: 0     Maxima: 65535
Channel - 'Default' :     Minima: 0     Maxima: 65535