Move Pixel
Posted: 2016-07-27T03:19:29-07:00
Can ImageMagick move pixels to another file?
Use https://github.com/ImageMagick/ImageMagick/discussions instead.
https://download.imagemagick.org/discourse-server/
https://download.imagemagick.org/discourse-server/viewtopic.php?t=30173
I don't understand this part.a.s. wrote:So we need an algorithm to randomly take approx. 50% of all pixels away from each 1-bit BMP file and "move" them into a new, separated file.
By "deleting" pixels, do you mean making them transparent? So the pixels in the new file that weren't copied will also be transparent?a.s. wrote:The algorithm randomly "selects" 500 pixels, stores them in a new file and deletes them in the source file.
Code: Select all
set SRC=toes.png
%IM%convert ^
%SRC% ^
( +clone ^
+noise Random ^
-channel R -separate +channel ^
-threshold 50%% ^
) ^
-compose CopyOpacity -composite ^
+write old.png ^
-channel A -negate +channel ^
new.png
Code: Select all
%IMG7%magick convert ^
logo: ^
-colorspace CMYK -channel C -negate -separate -monochrome ^
( +clone ^
+noise Random ^
-channel R -separate +channel ^
-threshold 50%% ^
) ^
-compose CopyOpacity -composite ^
+write logo_C_P1.bmp ^
-channel A -negate +channel ^
logo_C_P2.bmp
Code: Select all
set PREF=test-2pass
%IMG7%magick convert ^
%PREF%.bmp ^
( -clone 0 ^
-colorspace CMYK -channel C -negate -separate -monochrome ^
+write mpr:IMG ^
+noise Random ^
-channel R -separate +channel ^
-threshold 50%% ^
+write mpr:MASK ^
-delete 0 ^
mpr:IMG mpr:MASK ^
-compose Lighten -composite ^
+write %PREF%_P0_C.bmp ^
+delete ^
mpr:IMG ( mpr:MASK -negate ) ^
-compose Lighten -composite ^
+write %PREF%_P1_C.bmp ^
+delete ) ^
( -clone 0 ^
-colorspace CMYK -channel M -negate -separate -monochrome ^
+write mpr:IMG ^
+noise Random ^
-channel R -separate +channel ^
-threshold 50%% ^
+write mpr:MASK ^
-delete 0 ^
mpr:IMG mpr:MASK ^
-compose Lighten -composite ^
+write %PREF%_P0_M.bmp ^
+delete ^
mpr:IMG ( mpr:MASK -negate ) ^
-compose Lighten -composite ^
+write %PREF%_P1_M.bmp ^
+delete ) ^
( -clone 0 ^
-colorspace CMYK -channel Y -negate -separate -monochrome ^
+write mpr:IMG ^
+noise Random ^
-channel R -separate +channel ^
-threshold 50%% ^
+write mpr:MASK ^
-delete 0 ^
mpr:IMG mpr:MASK ^
-compose Lighten -composite ^
+write %PREF%_P0_Y.bmp ^
+delete ^
mpr:IMG ( mpr:MASK -negate ) ^
-compose Lighten -composite ^
+write %PREF%_P1_Y.bmp ^
+delete ) ^
( -clone 0 ^
-colorspace CMYK -channel K -negate -separate -monochrome ^
+write mpr:IMG ^
+noise Random ^
-channel R -separate +channel ^
-threshold 50%% ^
+write mpr:MASK ^
-delete 0 ^
mpr:IMG mpr:MASK ^
-compose Lighten -composite ^
+write %PREF%_P0_K.bmp ^
+delete ^
mpr:IMG ( mpr:MASK -negate ) ^
-compose Lighten -composite ^
+write %PREF%_P1_K.bmp ^
) ^
NULL: