align by pixel?

JAW

Gawd
Joined
Feb 8, 2004
Messages
518
Say I have a 100x100 pixel image, I also have another 10x10 pixel image. Is it possible to align the 10x10 over the 100x100 using pixel coordinates? Say like, coords="10,10,10,10" How would I set this up? I would create both images from scratch so software/format can be anything.
 
Well, I had one class (3 hours) about imaging the other day. A picture without compression is a matrix where the numbers in it are the numbers for each pixel color. We used Mathlab to modify an image with filters and do some other things. Therefore, with Mathlab, you can modify an image by using "coordinates" (matrix lines and columns). I can provide you with more info if you wish to work with Mathlab. Though, it is possible that there are better sowtwares to do that kind of stuff...

edit:
If you only have a 100x100 pixels you could also use any imaging software (photoshop) and manually count the pixels to locate your smaller image. Though, if you have multiple images to do, Mathlab (or better software I don't know about) would be better since you can program something that would automate the whole thing.

If it's a one deal thing, just count the pixel, IMO.
 
Yes, it is possible to exactly place images.
 
mikeblas, thanks for the informative post.

Is it possible to do in photoshop? I tried in fireworks and it works, only problem im having yet is how to save a PNG file with a transparent background. Everytime I save it in fireworks, it applies a background.
 
I'm happy to help. I just wish everyone would ask clearer, specific questions so I can quickly give perscriptive and accurate answers.

Now that we know you're using Photoshop, I think you can follow Vol's advice about counting pixels. Photoshop also has a grid which you can set to snap to your location very directly. You can nudge your selection with the arrow keys.

If your images are large, I'm not sure that using a program like mathlab to manipulate them as arrays would be useful. While the image data is an array, you've also got to write out (and read in) some header information to make the file valid for its format. I don't use Mathlab, but it's not something I'd want to try doing in Mathmatica.

Doing it in C# or VB.Net shouldn't take more than an hour.
 
Just to give out some information about the use of Mathlab which is more than easy IMO...

If you got Mathlab, this code should work (I couldn't try it since I don't have it installed at this time):
Code:
%Your 100x100 pixels image
A = double(imread('photo100x100','bmp'));

%Your 10x10 pixels image
B = double(imread('photo10x10','bmp'));

[m,n] = size(A);
[p,q] = size(B);

% The top left pixel in the 100x100 where the 10x10 should be put
row = 1;
column = 1;

% Put the 10x10 in the 100x100
for i = 1:p
    for j = 1:q
        A(row + i - 1 , column + j - 1) = (B(i , j));
    end
end

% Save the new image
imwrite(A,'new_photo100x100.bmp','bmp');

As you see, you don't have to edit all the information inside the image (i.e. header).



On a side note, if I have this with large bracket on each side :
Code:
1 2 3
4 5 6
7 8 9
Is it called a matrix or an array? I thought an array was only for one row matrix while a matrix was one or multiple rows of arrays. (that's usually how it is in French...)
 
Vol said:
Just to give out some information about the use of Mathlab which is more than easy IMO...

Interesting! I don't think it would be so straightforward in Mathematica.

Vol said:
As you see, you don't have to edit all the information inside the image (i.e. header).

What if I did this?

Code:
% The top left pixel in the 100x100 where the 10x10 should be put
row = 95;
column = 95;

That would change the size of the image, and I'd need to write a new header. Or was the intent of the question to clip the resulting image to 100x100?

Vol said:
Is it called a matrix or an array? I thought an array was only for one row matrix while a matrix was one or multiple rows of arrays. (that's usually how it is in French...)

If it is in a programming book, I'd call it a two-dimensional array. If it was in a maths book, I'd call it a matrix. A one-row matrix is called a vector.

If you know someone named Victor, it is fun to ask them: "What's the vector, Victor?"
 
If you change the row/column to 95, the pixels that are not defined by the "if loop" would get the value zero (but I'm not 100% about this). Then Mathlab would create the image header according to the dimension of the array.

In short, you can create an image directly from an array with Mathlab , you don't have to previously open an image like the above code.

Thanks for the clarification. Now that you explained it, I think it's the same in French :p
 
Back
Top