Monday, February 26, 2007

After an inspiring post from Bre Pettis, I decided to write my own rasterbator program in Matlab a few months ago. I'm sure after reading that first sentence, you're going to be angry and clueless about what I just said, so I'll wait for you to click on those links and then come back. Go on, I'll be waiting.....

And we're back! So it turned out great. It's a really simple code (although mine is a little inflexible, it works.... so whatever), so fellow matlab users, feel free to rasterbate your way into the history books:

% Joey Gerondale 1/22/07 Photo Splitter a.k.a. RASTERBATOR!
% The purpose of this simple program is to take a
% large JPEG file, split it into 16 equal sized
% pieces, and output those files as JPEGs.

% INITIALIZE

clc
clear all
IM=imread('your_pic.jpg','jpg');
[H W Z]=size(IM);
h=floor(H/4);
w=floor(W/4);

% COMPUTE

for k=1:4; %hblock
for r=1:4; %wblock
v(:,:,1)=IM(((k-1)*h+1):(k*h),((r-1)*w+1):(r*w),1); %assign red
v(:,:,2)=IM(((k-1)*h+1):(k*h),((r-1)*w+1):(r*w),2); %assign green
v(:,:,3)=IM(((k-1)*h+1):(k*h),((r-1)*w+1):(r*w),3); %assign blue
eval(['pic_out_' int2str(k) int2str(r) '=v;']);
end
end

% OUTPUT

imwrite(pic_out_11,'pic_out_11.jpeg','jpeg');
imwrite(pic_out_12,'pic_out_12.jpeg','jpeg');
imwrite(pic_out_13,'pic_out_13.jpeg','jpeg');
imwrite(pic_out_14,'pic_out_14.jpeg','jpeg');
imwrite(pic_out_21,'pic_out_21.jpeg','jpeg');
imwrite(pic_out_22,'pic_out_22.jpeg','jpeg');
imwrite(pic_out_23,'pic_out_23.jpeg','jpeg');
imwrite(pic_out_24,'pic_out_24.jpeg','jpeg');
imwrite(pic_out_31,'pic_out_31.jpeg','jpeg');
imwrite(pic_out_32,'pic_out_32.jpeg','jpeg');
imwrite(pic_out_33,'pic_out_33.jpeg','jpeg');
imwrite(pic_out_34,'pic_out_34.jpeg','jpeg');
imwrite(pic_out_41,'pic_out_41.jpeg','jpeg');
imwrite(pic_out_42,'pic_out_42.jpeg','jpeg');
imwrite(pic_out_43,'pic_out_43.jpeg','jpeg');
imwrite(pic_out_44,'pic_out_44.jpeg','jpeg');

I tried it out on this picture of a fish:



And (after I glued the 16 pieces back into one single picture) it turned out like this:

So, it works. In the very short-term, I think I have convinced Mike to scan his hairy ass...then we can use this to make an enormous-hairy-ass-poster and hang it somewhere on campus. A bit juvenile, I know, but I'm tempted nonetheless.

School is still stressful. This is a time of flux - I'll explain more later.

1 comment:

Stacey said...

I knew you were a rasterbator!!!