ImageMagickのコマンド遅さの問題

ダルシャン・パテル:

私は、画像からCMYKの色を識別するために、(UbuntuのOSでのバックエンドとしてJavaを使用して)私のWebアプリケーションでは、いくつかの画像処理のためのImageMagickを使用しています。

Orginial画像:

ここでは、画像の説明を入力します。

手順は、画像全体については、以下の通りです:

まず、私はCMYKのグレースケールで4つの画像を分離しています:

convert IMG_1732.jpg -colorspace CMYK -negate -separate IMG_1732-sep.jpg

以下のような4つの画像の結果:

画像1:

ここでは、画像の説明を入力します。

画像2:

ここでは、画像の説明を入力します。

画像3:

ここでは、画像の説明を入力します。

画像4:

ここでは、画像の説明を入力します。

私は、グレースケールからC、M、Y、K色の画像にそれぞれ変換するコマンドの下に実行しています。

convert IMG_1732-sep-0.jpg -channel C -combine IMG_1732-sep-00.jpg

結果1:

ここでは、画像の説明を入力します。

convert IMG_1732-sep-1.jpg -channel M -combine IMG_1732-sep-11.jpg

結果2:

ここでは、画像の説明を入力します。

convert IMG_1732-sep-2.jpg -channel Y -combine IMG_1732-sep-22.jpg

結果3:

ここでは、画像の説明を入力します。

convert IMG_1732-sep-3.jpg -channel K -combine IMG_1732-sep-33.jpg

結果4:

ここでは、画像の説明を入力します。

問題は、画像サイズが周りより2〜3メガバイト以下である、それはあまりにも多くの時間を取っている、です。また、より多くのRAMとCPUを消費するだけでなく。

  • どのように私はそれを最適化することができますか?ImageMagickの中の他のオプションまたは他の方法はありますか?
  • How can I know percentage of CYAN available in original image? Same as Magenta, Yellow and Black? Is it possible?
fmw42 :

It is not possible to have a color image for your number 4, if that was a channel separated from CMYK. All single channels will be grayscale. Also I cannot reproduce your exact colors. So either the image is different or changed or you have not told us all your processing steps.

Similar to Mark Setchell's command, I can write your command in one command line and get processing times of about 0.63 sec.

time convert image.jpg -colorspace cmyk -negate -separate \
\( -clone 0 -channel C -combine +write C.jpg \) \
\( -clone 1 -channel M -combine +write M.jpg \) \
\( -clone 2 -channel Y -combine +write Y.jpg \) \
\( -clone 3 -channel K -combine +write K.jpg \) \
null:

0.626s


C.jpg ここでは、画像の説明を入力します。

M.jpg ここでは、画像の説明を入力します。

Y.jpg ここでは、画像の説明を入力します。

K.jpg ここでは、画像の説明を入力します。

あなたはファイルサイズを小さくしたい場合は、単に+書き込みの前に括弧内の各コマンドに-quality XXを追加します。またはPOSTプロセスの各結果の画像にいくつかのJPGのオプティマイザツールを見つけます。ImageMagickには、最も効率的なコンプレッサーではないかもしれないのlibjpegを、使用しています。私がチェックし、あなたの入力し、すべての私の出力結果は、-quality 95を使用しています。

私は-normalizeは、コントラストを高めるために含まれている場合、私は近い検索結果を得ることができますが、処理時間は約0.83秒に上がります。

convert image.jpg -colorspace cmyk -negate -separate -normalize \
\( -clone 0 -channel C -combine +write C.jpg \) \
\( -clone 1 -channel M -combine +write M.jpg \) \
\( -clone 2 -channel Y -combine +write Y.jpg \) \
\( -clone 3 -channel K -combine +write K.jpg \) \
null:

ここでは、画像の説明を入力します。

ここでは、画像の説明を入力します。

ここでは、画像の説明を入力します。

ここでは、画像の説明を入力します。

どのように私は、元の画像で利用可能なCYANの割合を知ることができますか?マゼンタ、イエロー、ブラックと同じ?

convert image.jpg -colorspace CMYK -format "%[fx:mean.c], %[fx:mean.m], %[fx:mean.y], %[fx:mean.k]\n" info: 

出力: 0.0606194、0.0598201、0.0300933、0.0748128

これらの値は、乗算各平均端にコロンが必要とされる100親切音符パーセント1.範囲0で画分です。

おすすめ

転載: http://43.154.161.224:23101/article/api/json?id=225915&siteId=1
おすすめ