for x=0:39
pic=strcat('location1',num2str(x),'.bmp');
pic2=strcat('location2',num2str(x),'.bmp');
a = uint8(imread(pic));
imwrite(a,pic2,'bmp');
end
This came from the need to convert the frames of an avi to 8 bit depth
bitmaps, and all the programs I could find not giving the option to
export at lower bit depths. So if anyone knows how to get matlab or
really anything to extract the frames as 8 bit depth bitmaps on its
own then that would be just as useful if not more.
pic=strcat('location1',num2str(x),'.bmp');
pic2=strcat('location2',num2str(x),'.bmp');
a = uint8(imread(pic));
imwrite(a,pic2,'bmp');
testa=imread(pic2);
isa(testa,'uint8')
imfinfo(pic2)
The image is uint8 ...
Regards,
Bodorin
I think he was asking something different. Both 8 bit BMP and 24 bit
BMP are stored as uint8. If you load in a BMP file that is 24 bit,
the imfinfo function will reveal that the bit depth parameter is 24.
For an 8 bit BMP, the bit depth parameter is 8. I believe he is
wondering how to convert a BMP with 24 bit bit depth into one with 8
bit depth.
I had wondered this myself at one point and am curious to know if
Matlab can do this. Anyone know?
Jim
----------------------------------------------------------------------------------------------------
Brian:
You extract them as they are written. If you want to convert them
after that, then that's fine but it's an extra step. Did you convert
"a" to a monochrome image?
It's probably still a 24 bit RGB image.
Here's some sample code that may help you:
clc;
clear all;
close all;
workspace;
% Read in standard RGB MATLAB demo image.
rgbImage = imread('peppers.png');
[rows columns numberOfColorPlanesRGB] = size(rgbImage)
% Convert to monochrome using default formula.
monoImage = uint8(rgb2gray(rgbImage));
[rows columns numberOfColorPlanesMono] = size(monoImage)
filename = 'rgbImage.bmp';
imwrite(rgbImage, filename, 'bmp');
filename = 'monoImage.bmp';
imwrite(monoImage, filename, 'bmp');
% Test that it's still 8 bit monochrome by reading it back in.
readBackIn = imread(filename);
[rows columns numberOfColorPlanesNew] = size(readBackIn)
Note that on disk the monochrome version is 194 kb while the RGB
version is 577 kb, so that also verfies that it's 8 bit monochrome.
Regards,
Bodorin
Brian <abi...@gmail.com> wrote in message <0b497d67-2222-4d68...@l32g2000vba.googlegroups.com>...
> How to do that conversion step is what I'm looking for. What you've
> posted is useful, but ideally I'd still have a color image after the
> conversion, simply with less color variation than the 24 bit depth.