Hi every one again..
I have a doubt which is smthing lik this.... i have a one-dimension array which contain r,g,b values in differnet offsets of an image and based on some calculations i make some changes to the pixels...i want to reflect these changes in image by changing the pixels in original image with the new values which i get after calculations.
Can anyone please tell me how to do this in image magick ?
Thanks in advance.
Manipulate Image
-
- Posts: 43
- Joined: 2011-10-01T14:34:04-07:00
- Authentication code: 8675308
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Manipulate Image
I presume you have a 1D image of RGB values in some standard format such as gif or tiff or png, etc. And you want to replace some pixels with different colors at specific locations. There are several approaches. The easiest or most efficient may be to just draw those colored pixels at the locations you want
see
http://www.imagemagick.org/Usage/draw/#primitives
see
http://www.imagemagick.org/Usage/draw/#primitives
-
- Posts: 43
- Joined: 2011-10-01T14:34:04-07:00
- Authentication code: 8675308
Re: Manipulate Image
fmw42 wrote:I presume you have a 1D image of RGB values in some standard format such as gif or tiff or png, etc. And you want to replace some pixels with different colors at specific locations. There are several approaches. The easiest or most efficient may be to just draw those colored pixels at the locations you want
see
http://www.imagemagick.org/Usage/draw/#primitives
Thanks for reply..but i want it in programmatical way...not command arguments...
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Manipulate Image
A shell script will allow you to program the changes using the IM command line commands
-
- Posts: 43
- Joined: 2011-10-01T14:34:04-07:00
- Authentication code: 8675308
Re: Manipulate Image
Thankyou..can u provide an example please..iam novoice in shell scripting.fmw42 wrote:A shell script will allow you to program the changes using the IM command line commands
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Manipulate Image
Here is a simple unix bash script that will create a 1D horizontal gradient and put 3 different rgb colors at different locations as specified from a text file.
Save the following as a file called whatever you want. I used test_changecolor
Here is the infile=textfile.txt that contains the 3 colors and positions to place them. Note that there is no return or new line after the last color position.
See
http://www.imagemagick.org/Usage/draw/
http://www.imagemagick.org/Usage/draw/#primitives
http://www.imagemagick.org/Usage/draw/#mvg
http://www.imagemagick.org/script/magic ... aphics.php
Save the following as a file called whatever you want. I used test_changecolor
Code: Select all
#!/bin/bash
# define file of colors and positions
infile="testfile.txt"
# create 1D gradient as test image
convert -size 1x256 gradient: -rotate 90 grad1x256.png
# set up string for -draw from colors and positions
string=""
while read color position; do
string="$string fill $color point $position"
done < $infile
# color gradient from colors and positions in infile
convert grad1x256.png -draw "$string" grad1x256_colors.png
exit 0
Code: Select all
rgb(255,0,0) 25,0
rgb(0,255,0) 50,0
rgb(0,0,255) 100,0
http://www.imagemagick.org/Usage/draw/
http://www.imagemagick.org/Usage/draw/#primitives
http://www.imagemagick.org/Usage/draw/#mvg
http://www.imagemagick.org/script/magic ... aphics.php
-
- Posts: 43
- Joined: 2011-10-01T14:34:04-07:00
- Authentication code: 8675308
Re: Manipulate Image
Thankq very much....fmw42 wrote:Here is a simple unix bash script that will create a 1D horizontal gradient and put 3 different rgb colors at different locations as specified from a text file.
Save the following as a file called whatever you want. I used test_changecolor
Here is the infile=textfile.txt that contains the 3 colors and positions to place them. Note that there is no return or new line after the last color position.Code: Select all
#!/bin/bash # define file of colors and positions infile="testfile.txt" # create 1D gradient as test image convert -size 1x256 gradient: -rotate 90 grad1x256.png # set up string for -draw from colors and positions string="" while read color position; do string="$string fill $color point $position" done < $infile # color gradient from colors and positions in infile convert grad1x256.png -draw "$string" grad1x256_colors.png exit 0
SeeCode: Select all
rgb(255,0,0) 25,0 rgb(0,255,0) 50,0 rgb(0,0,255) 100,0
http://www.imagemagick.org/Usage/draw/
http://www.imagemagick.org/Usage/draw/#primitives
http://www.imagemagick.org/Usage/draw/#mvg
http://www.imagemagick.org/script/magic ... aphics.php