To resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016
Hello, I wrote a script creating number of files, each one containing x,y,z coordinates of four different points (practically a 3x4 matrix ). How can I now transform these files in binary image files? I would like then to stack each set of 24 binary images into single 24bit image in a way such that instead of being identified with one digit (0 or 1) each pixel should be identified with 24 (101111....), each digit corresponding to the value of the relevant pixel of every single binary image. Thank you!
No products are associated with this question.
I didn't quite follow what you're generating and don't know the range of your numbers or which one is supposed to be the red, green, and blue, or if your 24 bit image is an RGB image or a 24 bit grayscale image, or how you're defining "binary". In image processing, binary means a 0 or 1 logical/boolean image. If so, then that's not a 24 bit RGB image with 8 bits (0-255) for the red value, 8 bits for the green value, and 8 bits for the blue value. Maybe you mean binary, like all computer variables are binary, of course. I have no idea. So overall, it's not clear what you want. But in general you can instantiate a color image like this:
rgbImage = zeros(300, 400, 3, 'uint8');
and then assign values like this:
rgbImage(row, column, 1) = redValue; rgbImage(row, column, 2) = greenValue; rgbImage(row, column, 3) = blueValue;
Make sure the values are in the range 0-255 if you want to display the image with imshow() or image(). Scale them and cast to uint8 if you have to.
I don't know if this will help, but I thought I would try it. Basically it takes a 3 dimensional logical matrix (n x 24) and converts it to a n x 3 RGB matrix. I'm sure there are better implementations; just can't think of them now.
a = rand(20,20,24); b = a < .15; %create logical matrix
cb = char(b+48); rgb = zeros(20,20,3);
for m = 1:3 for c = 1:20 for r = 1:20 t = squeeze(cb(r,c,m*(1:8)))'; rgb(r,c,m) = bin2dec(t); end end end imshow (rgb,'InitialMagnification','Fit')