I am trying to build a high resolution image that consist of vertical lines from other images.
To be exact: I want to build an image that is 3888×2592 pixels. I want to build it using 3888 vertical lines that are 2592 pixels high. I have a folder with 3888 high resolution images and the new image should be build by extracting vertical line number one from the first picture, vertical line number two from the second picture, vertical line number three from the third picture and so on.
Here is a very simple illustration:
Click illustration to enlarge.
It would be possible to do this manually in photoshop. Open one image, cut the first column of pixels, paste in a new image and repeat 3888 times… But this is something that would be much easier by automation. Pseudo code:
– Create new image, 3888×2592
For n = 1 to 3888
– Open image number n
– Copy column number n (1×2592 pixels)
– Paste at column number n in new image
Next n
…the problem is that I have no idea what tool to use. Could this be programmed using automator and apple script? Using automation in photoshop? Or do I need to learn xcode and do it the hard way?
Preferably a solution that could be done on a Mac.
Any advice is appreciated!
Hvis jeg tolker Mono riktig så er system.drawing implementert. Du skal da kunne kopiere deler av et bilde (heter bitmap i system.drawing verden) inn i et annet.
Se http://msdn.microsoft.com/en-us/library/aa457087.aspx
Men hvis du ikke har jobbet med Mono før så finner du sikkert noe enklere.
Hva med perl/bash/php in combination with imagemagic convert command line tool?
I would probably solve it with PHP.
http://www.php.net/manual/en/function.imagecopy.php
you could run PHP locally
http://developer.apple.com/internet/opensource/php.html
Høres ut som en jobb for Processing. http://processing.org/
Dette kan være et tilfelle av at jeg har en hammer og at det får alt til å se ut som en spiker, men det burde være nokså enkelt å få til dette med GD i PHP.
Se http://php.net/manual/en/function.imagecopy.php for et utgangspunkt – bare pass på å kvitt deg med bildene i minnet med imagedestroy() etterhvert som du laster inn nye, ellers går du nok tom for minne.
Tenkte faktisk på processing. Det er programmering på et nivå som passer for en “casual programmer”…
This could probably be easily done in FSL (freely available for linux and mac, at http://www.fmrib.ox.ac.uk/fsl/), using the command line tools fslroi and fslmerge, and a simple bash script. I would rename the source images according to the number of the line you want (starting at 0, again with a simple bash script). Then make a list of your files, without the extension. Do something like this in bash, ‘while read LINE ; do fslroi ${LINE}.jpg ${LINE}_extracted.jpg ${LINE} 1 0 2591 0 0 ; done < list'. Then 'fslmerge -x merged_in_x_direction.jpg files…'
ImageMagick?
I would have used Java. Most likely because that is the programming language I have the most experience with, but also because the Java2D API is fairly easy and Java runs cross platform.
This is done easily with ImageMagick and a little bash scripting:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
eirikmagick.sh
hosted with ❤ by GitHub
After you have installed imagemagick and curl, open a terminal window and cd to your image folder. Then run:
curl https://gist.github.com/raw/739744/f262f94a1a79f0c89bd4e2c56f1f40922cd81567/eirikmagick.sh | sh
You’ll find your new image in out.png in the same folder.
Feel free to tweak the script online by forking my gist. Follow the “raw” link to get the URL of your updated script.
Thank you! (-:
Eirik,
Assuming you’ve got ImageMagick correctly installed on your Mac, this would be one way to do it, using perl.
This example assumes 16 gif files named 01.gif trough 15.gif, and every one 16×16 pixels big. The script crops out one pixel wide row from each gif and creates a new gif file for each. In the end the script merges all of them into one single gif file.
I’m not sure whether this would work with images sized like yours — I think you may run into command line limitations on the final command/line here — but hopefully this’ll give you a starting point.
#!/usr/bin/perl
use strict;
my ($cropwidth, $cropheight) = (1, 16);
my $i = 1; # Assumes that first file is named 01.extension
my $filetype = “.gif”; # Change to whatever extension you use
my $maxfiles = 15;
my $flattenedfile = “flattened” . $filetype;
while ($i <= $maxfiles) {
# Change %02d to %03d if three digit number, %04d if four digits etc.
my $filename = sprintf("%02d", $i) . $filetype;
my $offset = $i – 1;
my $convertedfile = "converted-" . $filename;
`convert $filename -crop ${cropwidth}x${cropheight}+$offset $convertedfile`;
$i++;
}
`convert converted-*$filetype -background white -mosaic $flattenedfile`;
Solved with Python Imaging Lib. ( http://www.pythonware.com/products/pil/ )
Solution here: http://dpaste.org/DD3w/
Hi,
you can try with Matlab, it is very easy to learn..
Mail me if you need help
You should be able to make a comp in Quartz Composer (part of OSX dev-kit). I have no time to do this right now, but the nodes in Quartz are quite self-explaining.
Definitely a well suited task for PHP and GD/ImageMagick. +1 from me.
Funny to see that no one seems to wonder what the heck you try to create.
(and just hand you solutions which is a good thing of course)
I just became very interested in what is behind your question.
The only useful result would be from a series of pictures that are fairly similar.
Like a stop-motion sequence or a time-lapse series.
Or a self-portrait shot every day for the last ten years.
Do you want to capture time and/or motion in your result?
Can you share some of your thoughts or do we have to wait for the result?
Hehe. We’re talking solution oriented and pretty fantastic people here. 🙂
Aslak’s solution is the one I’m playing around with now. And you are right. This year’s time lapse project is my old Canon 400D that have been mounted in my window for nearly a year now. Snapping an image every half hour…
So, I have a repository of images shot at EXACTLY the same place now. Around 15 000 of them actually.
And now I have started to play with the content. Making time lapse trials and this little project: making an image that consist of 3888 other images snapped all through one year.
This is the quick test Aslak did on around 300 images I sent him:
http://yfrog.com/h44kpdj
I’m working on the 3888-lines-version now. I promise I’ll post more on this later!
Thank you for keeping us up to date.
Looks very promising.
It will be hard though to match the impact and awesomeness of your time lapse video.
Unless….
you make a video of shifting sliced up pictures…
See the seasons slide from left to right.
Just a thought.
And a hell of a job 🙂
Its very easy with Cuda. Nice to do big Shit like that on the Gpu. Proccessing all this on the Cpu takes about 50 times longer than on a decent Gpu. Once you have mastered image processing on Gpu/Cuda, there are very few things you cant do.
http://www.nvidia.com/object/cuda_home_new.html
http://www.codeproject.com/KB/graphics/blurringwithcuda.aspx
http://developer.nvidia.com/object/nvision08-ImageVideoCUDA.html
Click to access DV40.pdf
This is TRIZ…DaVinci 40 Answers, free pdf…AND takes any challenge to the level of infinite possibilities in solution.
Saw your 40 second video on http://www.mercola.com and was deLIGHTed in gratitude.
Warm hug,
KB
that’s some problem you got there.. but I’m not progamming guru but I would suggest an open source image editor w/ an slicer that can slice your image 1 pixel column per image, then just reprogram it to your algorithm to create a new image. Probably one that has a batch process feature.
[…] have from 2010 are 3888×2592 pixels. So I selected 3888 images snapped during the day. Then I got some generous help from my blog readers and twitter followers. To make a script that would take one line from the first image, the next […]
[…] fikk hjelp til å lage et script som gjorde jobben for meg etter å ha beskrevet problemet på bloggen min. Både Jo Christian Oterhals, Nikolai Kristiansen og Aslak Hellesøy kom med komplette løsninger. […]
I was looking at this and thinking about how the somewhat abrupt transitions and vertical lines could be ameliorated. The easiest way to do it would be to slice into three pixel panels, glue them together (ending up with an image 3x the final width), and then run through a lossy 2d convolution like [0.2, 0, 0.6, 0, 0.2] on the center column of each panel. That way each column would end up being 20% of yesterday, 60% of today, and 20% of tomorrow.
[…] Luckily I found an already made script that did what I wanted it to do. What the script does is to cut out a vertical slice (a few pixels wide) of each picture in a folder and then “glue” them together into one picture in chronological order. The process is described in detail on this page. […]
I would love to combine Onno ter Wisscha’s and Peter da Silva’s suggestions. It would make such a beautiful video!
I would program this using ImageMagick and mencoder.
It would be great if you were able to upload these images somewhere, maybe as a torrent?
[…] by his window and took a photo every half an hour and ended up with 16,000 photos. I also used Aslak Hellesøy ‘s eirikmagick.sh script to generate my full-year picture. These are known as HDTR (high […]