how do i do this in ImageMagick, please help...

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
arun4444

how do i do this in ImageMagick, please help...

Post by arun4444 »

i'd like to make the following image twice as high and twice as wide. It must be made twice as wide by placing an extra copy of each column next to the original column. It has to be made twice as wide by placing a black line between each row of the image.

http://land.t-a-y-l-o-r.com/hamb_orgR.png

Thank you very much, i am excited :D
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: how do i do this in ImageMagick, please help...

Post by fmw42 »

arun4444 wrote:i'd like to make the following image twice as high and twice as wide. It must be made twice as wide by placing an extra copy of each column next to the original column. It has to be made twice as wide by placing a black line between each row of the image.

Please clarify your question. Are you requesting two different methods for making it twice as WIDE? Or is one for making twice as WIDE and the other for making it twice as HIGH?

If the latter, then this seems to work.

scale the input to double every pixel
create white and black alternating rows image and convert white to transparent
overlay the second image over the first

Image

infile="hamb_orgR.png"
outfile="hamb_orgR2.png"
ww=`identify -ping -format "%w" $infile`
hh=`identify -ping -format "%h" $infile`
ww=`convert xc: -format "%[fx:2*$ww]" info:`
hh=`convert xc: -format "%[fx:2*$hh]" info:`
convert \( $infile -scale 200% \) \
\( -size 1x1 xc:white xc:black -append \
-write mpr:stripes +delete -size ${ww}x${hh} tile:mpr:stripes -transparent white \) \
-compose over -composite $outfile

Image
arun4444

Re: how do i do this in ImageMagick, please help...

Post by arun4444 »

Perfect,

Just what i wanted.

To elaborate a bit more, i am in the process of presenting a project in my physics class,

The experiment is shown in this video from 43:30 to 50:00

http://www.youtube.com/watch?v=ab0czJ6_OF8

i'd like to replicate each step in imagemagick.

if you know of a good way to do this, please let me know.

Best,
arun
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: how do i do this in ImageMagick, please help...

Post by fmw42 »

I don't think many reader's of this forum are going to watch a 50 min video on Lec 29 | MIT 8.02 Electricity and Magnetism, Spring 2002. What exactly are you trying to demonstrate from this video and how will image processing and IM in particular help you do that? I don't see any photos in the lecture except for the Land slides demonstrating color generated from two black and white slides taken with different filters.
arun4444

Re: how do i do this in ImageMagick, please help...

Post by arun4444 »

Basically i'd like to know the procedure for doing the following in imagemagick

http://land.t-a-y-l-o-r.com/

so that i make replicate it on another image used in my presentation.

Thank you very very much

Best,
arun
arun4444

Re: how do i do this in ImageMagick, please help...

Post by arun4444 »

please :(
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: how do i do this in ImageMagick, please help...

Post by fmw42 »

arun4444 wrote:Basically i'd like to know the procedure for doing the following in imagemagick

http://land.t-a-y-l-o-r.com/


infile="hamburger.png"
Image

# get name before the .png
inname=`convert $infile -format "%t" info:`

# separate channels
convert $infile -separate ${inname}.png

outfile="hamburger_land.png"

# get double size for output
ww=`identify -ping -format "%w" $infile`
hh=`identify -ping -format "%h" $infile`
ww=`convert xc: -format "%[fx:2*$ww]" info:`
hh=`convert xc: -format "%[fx:2*$hh]" info:`

# take input and double it, then make green and blue channels black
# create striped image with first white, then black alternating and make white transparent
# overlay black stripes over red image
convert \( ${inname}.png -scale 200% -fill black -colorize 0,100,100 \) \
\( -size 1x1 xc:white xc:black -append \
-write mpr:stripes +delete -size ${ww}x${hh} tile:mpr:stripes -transparent white \) \
-compose over -composite tmp1.png

# take green channel only (as grayscale) and double it
# create striped image with first black, then white alternating and make white transparent
# overlay black stripes over grayscale green channel image
convert \( ${inname}-1.png -scale 200% \) \
\( -size 1x1 xc:black xc:white -append \
-write mpr:stripes +delete -size ${ww}x${hh} tile:mpr:stripes -transparent white \) \
-compose over -composite tmp2.png

# make black stripes in both images transparent and composite the two images
convert \( tmp1.png -transparent black \) \
\( tmp2.png -transparent black \) \
-compose over -composite $outfile

Image

Personally, I don't see any green or yellow in either my version or the one referenced and I am not color blind.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: how do i do this in ImageMagick, please help...

Post by anthony »

An alternative way of adding black stripes is to -compose multiply the balck-white striped image with the original. black goes to black, white is left alone.

As for making that striped image. look at the built-in images
http://www.imagemagick.org/script/forma ... tin-images

the image of interest is pattern:gray50 Yes it is a pixel level checker board. But one column (any column) of pixels is alternative black and white images. You wanted white at the very top so pick the 'second' column.

So for a 100x100 pixel image of alternative lines...

Code: Select all

convert -size 1x100 -tile-offset +0+1 pattern:gray50  -scale 100x100\!  strips.gif
If you want black at the top, change the tiling offset to the default +0+0


I have added this to the 'deinterlacing' seciont in IM Examples, Videos
http://www.imagemagick.org/Usage/video/##deinterlace
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply