関数・クラス解説

Imagick::morphology

version:No version information available (公式)

Description

公式リファレンス

書式

public Imagick::morphology ( int $morphologyMethod , int $iterations , ImagickKernel $ImagickKernel [, int $channel = Imagick::CHANNEL_DEFAULT ] ) : bool

説明

Applies a user supplied kernel to the image according to the given morphology method.

パラメータ

morphologyMethod
Which morphology method to use one of the \Imagick::MORPHOLOGY_* constants.
iterations
The number of iteration to apply the morphology function. A value of -1 means loop until no change found. How this is applied may depend on the morphology method. Typically this is a value of 1.
ImagickKernel
channel

返値

成功した場合に TRUE を返します。

サンプル

例1 Convolve Imagick::morphology()

        $imagick = $this->getCharacter();         $kernel = \ImagickKernel::fromBuiltIn(\Imagick::KERNEL_GAUSSIAN, "5,1");         $imagick->morphology(\Imagick::MORPHOLOGY_CONVOLVE, 2, $kernel);         header("Content-Type: image/png");         echo $imagick->getImageBlob();

例2 Correlate Imagick::morphology()

        // Top-left pixel must be black         // Bottom right pixel must be white         // We don't care about the rest.                  $imagick = $this->getCharacterOutline();         $kernel = \ImagickKernel::fromMatrix(self::$correlateMatrix, [2, 2]);         $imagick->morphology(\Imagick::MORPHOLOGY_CORRELATE, 1, $kernel);         header("Content-Type: image/png");         echo $imagick->getImageBlob();

例3 Erode Imagick::morphology()

        $canvas = $this->getCharacterOutline();         $kernel = \ImagickKernel::fromBuiltIn(\Imagick::KERNEL_OCTAGON, "3");         $canvas->morphology(\Imagick::MORPHOLOGY_ERODE, 2, $kernel);         header("Content-Type: image/png");         echo $canvas->getImageBlob();

例4 Erode Intensity Imagick::morphology()

        $canvas = $this->getCharacter();         $kernel = \ImagickKernel::fromBuiltIn(\Imagick::KERNEL_OCTAGON, "1");         $canvas->morphology(\Imagick::MORPHOLOGY_ERODE_INTENSITY, 2, $kernel);         header("Content-Type: image/png");         echo $canvas->getImageBlob();

例5 Dilate Imagick::morphology()

        $canvas = $this->getCharacterOutline();         $kernel = \ImagickKernel::fromBuiltIn(\Imagick::KERNEL_OCTAGON, "3");         $canvas->morphology(\Imagick::MORPHOLOGY_DILATE, 4, $kernel);         header("Content-Type: image/png");         echo $canvas->getImageBlob();

例6 Dilate intensity Imagick::morphology()

        $canvas = $this->getCharacter();         $kernel = \ImagickKernel::fromBuiltIn(\Imagick::KERNEL_OCTAGON, "1");         $canvas->morphology(\Imagick::MORPHOLOGY_DILATE_INTENSITY, 4, $kernel);         header("Content-Type: image/png");         echo $canvas->getImageBlob();

例7 Distance with Chebyshev kernel Imagick::morphology()

        $canvas = $this->getCharacterOutline();         $kernel = \ImagickKernel::fromBuiltIn(\Imagick::KERNEL_CHEBYSHEV, "3");         $canvas->morphology(\Imagick::MORPHOLOGY_DISTANCE, 3, $kernel);         $canvas->autoLevelImage();         header("Content-Type: image/png");         echo $canvas->getImageBlob();

例8 Distance with Manhattan kernel Imagick::morphology()

        $canvas = $this->getCharacterOutline();         $kernel = \ImagickKernel::fromBuiltIn(\Imagick::KERNEL_MANHATTAN, "5");         $canvas->morphology(\Imagick::MORPHOLOGY_DISTANCE, 3, $kernel);         $canvas->autoLevelImage();         header("Content-Type: image/png");         echo $canvas->getImageBlob();

例9 Distance with ocatagonal kernel Imagick::morphology()

        $canvas = $this->getCharacterOutline();         $kernel = \ImagickKernel::fromBuiltIn(\Imagick::KERNEL_OCTAGONAL, "5");         $canvas->morphology(\Imagick::MORPHOLOGY_DISTANCE, 3, $kernel);         $canvas->autoLevelImage();         header("Content-Type: image/png");         echo $canvas->getImageBlob();

例10 Distance with Euclidean kernel Imagick::morphology()

        $canvas = $this->getCharacterOutline();         $kernel = \ImagickKernel::fromBuiltIn(\Imagick::KERNEL_EUCLIDEAN, "4");         $canvas->morphology(\Imagick::MORPHOLOGY_DISTANCE, 3, $kernel);         $canvas->autoLevelImage();         header("Content-Type: image/png");         echo $canvas->getImageBlob();

例11 Edge Imagick::morphology()

        $canvas = $this->getCharacterOutline();         $kernel = \ImagickKernel::fromBuiltIn(\Imagick::KERNEL_OCTAGON, "3");         $canvas->morphology(\Imagick::MORPHOLOGY_EDGE, 1, $kernel);         header("Content-Type: image/png");         echo $canvas->getImageBlob();

例12 Open Imagick::morphology()

        // As a result you will see that 'Open' smoothed the outline, by rounding off any sharp points, and remove any parts that is smaller than the shape used. It will also disconnect or 'open' any thin bridges.         $canvas = $this->getCharacterOutline();         $kernel = \ImagickKernel::fromBuiltIn(\Imagick::KERNEL_DISK, "6");         $canvas->morphology(\Imagick::MORPHOLOGY_OPEN, 1, $kernel);         header("Content-Type: image/png");         echo $canvas->getImageBlob();

例13 Open intensity Imagick::morphology()

        // As a result you will see that 'Open' smoothed the outline, by rounding off any sharp points, and remove any parts that is smaller than the shape used. It will also disconnect or 'open' any thin bridges.         $canvas = $this->getCharacter();         $kernel = \ImagickKernel::fromBuiltIn(\Imagick::KERNEL_DISK, "6");         $canvas->morphology(\Imagick::MORPHOLOGY_OPEN_INTENSITY, 1, $kernel);         header("Content-Type: image/png");         echo $canvas->getImageBlob();

例14 Close Imagick::morphology()

        //The basic use of the 'Close' method is to reduce or remove any 'holes' or 'gaps' about the size of the kernel 'Structure Element'. That is 'close' parts of the background that are about that size.         $canvas = $this->getCharacterOutline();         $kernel = \ImagickKernel::fromBuiltIn(\Imagick::KERNEL_DISK, "6");         $canvas->morphology(\Imagick::MORPHOLOGY_CLOSE, 1, $kernel);         header("Content-Type: image/png");         echo $canvas->getImageBlob();

例15 Close Intensity Imagick::morphology()

        //The basic use of the 'Close' method is to reduce or remove any 'holes' or 'gaps' about the size of the kernel 'Structure Element'. That is 'close' parts of the background that are about that size.         $canvas = $this->getCharacter();         $kernel = \ImagickKernel::fromBuiltIn(\Imagick::KERNEL_DISK, "6");         $canvas->morphology(\Imagick::MORPHOLOGY_CLOSE_INTENSITY, 1, $kernel);         header("Content-Type: image/png");         echo $canvas->getImageBlob();

例16 Smooth Imagick::morphology()

        $canvas = $this->getCharacterOutline();         $kernel = \ImagickKernel::fromBuiltIn(\Imagick::KERNEL_OCTAGON, "3");         $canvas->morphology(\Imagick::MORPHOLOGY_SMOOTH, 1, $kernel);         header("Content-Type: image/png");         echo $canvas->getImageBlob();

例17 Edge in Imagick::morphology()

        $canvas = $this->getCharacterOutline();         $kernel = \ImagickKernel::fromBuiltIn(\Imagick::KERNEL_OCTAGON, "3");         $canvas->morphology(\Imagick::MORPHOLOGY_EDGE_IN, 1, $kernel);         header("Content-Type: image/png");         echo $canvas->getImageBlob();

例18 Edge out Imagick::morphology()

        $canvas = $this->getCharacterOutline();         $kernel = \ImagickKernel::fromBuiltIn(\Imagick::KERNEL_OCTAGON, "3");         $canvas->morphology(\Imagick::MORPHOLOGY_EDGE_OUT, 1, $kernel);         header("Content-Type: image/png");         echo $canvas->getImageBlob();

例19 The 'TopHat' method, or more specifically 'White Top Hat', returns the pixels that were removed by a Opening of the shape, that is the pixels that were removed to round off the points, and the connecting bridged between shapes. Imagick::morphology()

        $canvas = $this->getCharacterOutline();         $kernel = \ImagickKernel::fromBuiltIn(\Imagick::KERNEL_DISK, "5");         $canvas->morphology(\Imagick::MORPHOLOGY_TOP_HAT, 1, $kernel);         header("Content-Type: image/png");         echo $canvas->getImageBlob();

例20 The 'BottomHat' method, also known as 'Black TopHat' is the pixels that a Closing of the shape adds to the image. That is the pixels that were used to fill in the 'holes', 'gaps', and 'bridges'. Imagick::morphology()

        $canvas = $this->getCharacterOutline();         $kernel = \ImagickKernel::fromBuiltIn(\Imagick::KERNEL_DISK, "5");         $canvas->morphology(\Imagick::MORPHOLOGY_BOTTOM_HAT, 1, $kernel);         header("Content-Type: image/png");         echo $canvas->getImageBlob();

例21 Hit and Miss Imagick::morphology()

        $canvas = $this->getCharacterOutline();         //This finds all the pixels with 3 pixels of the right edge         $matrix = [[1, false, false, 0]];         $kernel = \ImagickKernel::fromMatrix(             $matrix,             [0, 0]         );         $canvas->morphology(\Imagick::MORPHOLOGY_HIT_AND_MISS, 1, $kernel);         header("Content-Type: image/png");         echo $canvas->getImageBlob();

例22 Thinning Imagick::morphology()

        $canvas = $this->getCharacterOutline();         $leftEdgeKernel = \ImagickKernel::fromMatrix([[0, 1]], [1, 0]);         $rightEdgeKernel = \ImagickKernel::fromMatrix([[1, 0]], [0, 0]);         $leftEdgeKernel->addKernel($rightEdgeKernel);                  $canvas->morphology(\Imagick::MORPHOLOGY_THINNING, 3, $leftEdgeKernel);         header("Content-Type: image/png");         echo $canvas->getImageBlob();

例23 Thicken Imagick::morphology()

        $canvas = $this->getCharacterOutline();         $leftEdgeKernel = \ImagickKernel::fromMatrix([[0, 1]], [1, 0]);         $rightEdgeKernel = \ImagickKernel::fromMatrix([[1, 0]], [0, 0]);         $leftEdgeKernel->addKernel($rightEdgeKernel);         $canvas->morphology(\Imagick::MORPHOLOGY_THICKEN, 3, $leftEdgeKernel);         header("Content-Type: image/png");         echo $canvas->getImageBlob();

例24 Thick to generate a convex hull Imagick::morphology()

        $canvas = $this->getCharacterOutline();         $diamondKernel = \ImagickKernel::fromBuiltIn(\Imagick::KERNEL_DIAMOND, "1");         $convexKernel =  \ImagickKernel::fromBuiltIn(\Imagick::KERNEL_CONVEX_HULL, "");         // The thicken morphology doesn't handle small gaps. We close them         // with the close morphology.         $canvas->morphology(\Imagick::MORPHOLOGY_CLOSE, 1, $diamondKernel);         $canvas->morphology(\Imagick::MORPHOLOGY_THICKEN, -1, $convexKernel);         $canvas->morphology(\Imagick::MORPHOLOGY_CLOSE, 1, $diamondKernel);         header("Content-Type: image/png");         echo $canvas->getImageBlob();

例25 Iterative morphology Imagick::morphology()

        $canvas = $this->getCharacterOutline();         $kernel = \ImagickKernel::fromBuiltIn(\Imagick::KERNEL_DISK, "2");                 $canvas->morphology(\Imagick::MORPHOLOGY_ITERATIVE, 3, $kernel);         $canvas->autoLevelImage();         header("Content-Type: image/png");         echo $canvas->getImageBlob();

例26 Helper functon to get an image silhouette Imagick::morphology()

    private function getCharacterOutline() {         $imagick = new \Imagick(realpath("./images/character.png"));         $character = new \Imagick();         $character->newPseudoImage(             $imagick->getImageWidth(),             $imagick->getImageHeight(),             "canvas:white"         );         $canvas = new \Imagick();         $canvas->newPseudoImage(             $imagick->getImageWidth(),             $imagick->getImageHeight(),             "canvas:black"         );         $character->compositeimage(             $imagick,             \Imagick::COMPOSITE_COPYOPACITY,             0, 0         );         $canvas->compositeimage(             $character,             \Imagick::COMPOSITE_ATOP,             0, 0         );         $canvas->setFormat('png');         return $canvas;     }

ワード検索


※入力キーワードが、関数名・説明文・タグに含まれるものを検索

関数名アルファベット別

A B C D E F G H I J
K L M N O P Q R S T
U V W X Y Z _

最終更新一覧

stristr
 大文字小文字を区別せず文字列を検索し、ヒット箇所以降(あるいは以前)の文字列を返却

stripslashes
 バックスラッシュでエスケープされた文字列から、バックスラッシュを取り除く

stripos
 大文字小文字を区別せずに文字列が最初に現れる位置を取得する

stripcslashes
 addcslashes() でクォートされた文字列をアンクォートする

strip_tags
 文字列から HTML と PHP のタグを除去して返却

strcspn
 指定した文字が最初に現れる位置を調べる

strcoll
 ロケールに基づいて2つの文字列を比較し同じか(あるいは大小)を判定する

strcmp
 2つの文字列を比較し同じか(あるいは大小)を判定する

strchr
 strstr() のエイリアス

strcasecmp
 2つの文字列を比較(大文字小文字を区別せず同じとみなす)

カテゴリー一覧

PHP の振る舞いの変更
音声フォーマットの操作
認証サービス
コマンドライン関連
圧縮およびアーカイブ
暗号
データベース関連
日付および時刻関連
ファイルシステム
自然言語および文字エンコーディング
画像処理および作成
メール関連
数学
テキスト以外の MIME 型
プロセス制御
その他の基本モジュール
その他のサービス
検索エンジン用の拡張モジュール
サーバー固有のモジュール
セッション関連
テキスト処理
変数・データ型関連
ウェブサービス
Windows 用のモジュール
XML 操作
GUI用の拡張モジュール