使用 ImageMagick 改進從平面圖像到 3d 模型的轉換鏈 (Improve this conversion chain from flat images to 3d mockup with ImageMagick)


問題描述

使用 ImageMagick 改進從平面圖像到 3d 模型的轉換鏈 (Improve this conversion chain from flat images to 3d mockup with ImageMagick)

I was wondering about ways to improve or shorten an ImageMagick conversion (I am rather new to ImageMagick myself).

What I have is a flat image (left in 1) and a 3d mock up that has transparent areas (right in 1, the dashed gets filled, blue and grey are solid ontop) that get filled with the transformed flat image.

I played around with several ImageMagick commands, and list them here for each step (no real numbers). What I am looking for is how to shorten/combine this sequence and the number of helper images created to get to the final image:

  1. My given input images. (Scroll down to 5. to see how these two should be combined to get my wanted output...)

  2. Crop the flash image and skew the two resulting parts (I noticed that the crop command spits you out the cropped result and overflow, so I use that to separate the sides of the flat image):

    # sequence for left side:
    convert base.png -crop WxH parts.png
    convert parts-0.png -virtual-pixel transparent -distort Perspective /
            '....' (-resize WxH) front-skewed.png
    
    #[... same for the right side ...]
    
  3. Combine the skewed parts:

    convert front-skewed.png side-skewed.png +append fill.png
    
  4. Combine the skewed fill and the mockup cover/mask, so that the fill gets inserted under the transparent parts of the cover.png (right image):

    composite fill.png cover.png -compose dst-atop -matte final.png
    
  5. Result after deleting the unwanted intermediary images.

I will be running this from PHP via a exec, so any hint on how to do this more smoothly is welcome. I suppose I have to call each transformation as a seperate exec call, no?

This won't run excessively but only now and then when a new image gets added, so performance is not that much of a concern for me.


參考解法

方法 1:

In many cases you can put separate ImageMagick commands which are 'chained' (i.e. where a following command uses as input image the output image from a previous command) into one single command.

Since you do... 

  • ...neither provide your input images separately (your [good!] illustration has it 'all-in-one'),
  • ...nor your exact separate IM commands,... 

...I'm not inclined to construct my own example images and example commands to demonstrate and examplify this method.

I'll leave it at just pointing you to these resources:

  • Working with ordered lists of images
  • 'Cloning' or 'duplicating' images inside an ordered list of images
  • Parenthesis -- processing images 'on the side'
  • Sequencing image operations
  • Debugging complex operation sequences

(by konturKurt Pfeifle)

參考文件

  1. Improve this conversion chain from flat images to 3d mockup with ImageMagick (CC BY-SA 3.0/4.0)

#image-processing #imagemagick #exec #PHP #thumbnails






相關問題

在 matlab 中用 imread 讀取圖像文件會給出什麼樣的表示? (reading a image file with imread in matlab gives what kind of representation?)

使用 CRF 的圖像標記性能 (Image labeling performance using CRF)

Opencv:獲取圖像中的段大小並刪除小段 (Opencv: Get segments sizes in image and remove small segments)

將 PHP 頁面作為圖像返回 (Return a PHP page as an image)

我在哪裡可以找到有關雙三次插值和 Lanczos 重採樣的好讀物? (Where can I find a good read about bicubic interpolation and Lanczos resampling?)

從圖像中刪除白色背景 (Remove white backgrounds from images)

如何填充投影圖像的空白部分? (How to fill empty parts of a projected image?)

如何使圖像亮度均勻(使用 Python/PIL) (How to Make an Image Uniform Brightness (using Python/PIL))

圖像處理公式可生成類似通過 Mac 相機拍攝的照片的效果 (Image manipulation formula to generate effects like pictures taken via Mac's camera)

從照片生成漂亮的直方圖? (generating nice looking histogram from photo?)

使用 DjVu 工具進行背景/前景分離? (Using the DjVu tools to for background / foreground seperation?)

如何操縱跟踪器區域使其變成方形? (How can I manipulate the tracker area to make it into a square shape?)







留言討論