[Insight-users] Reading / Writing BMP images.

Luis Ibanez luis . ibanez at kitware . com
Tue, 30 Sep 2003 18:05:22 -0400


Hi Rashmi,


You are right,
The code in this message only shows how to write BMP.

You will have to write the equivalent code for reading,
otherwise there will not be any fun in the task   :-)

Since the BMP header has a quite static formatting
you may follow the same structure for reading.

A good starting point is to basically replace the
bmpFile ofstream with an ifstream and then replace
all the "write" methods in the with "read" methods.

Note that BMP use some padding at the end of the lines,
this padding should be removed before you pass data
from the read lines into your image buffer.
An ImageLinearIterator may be userful in this process.
http://www . itk . org/Insight/Doxygen/html/classitk_1_1ImageLinearIteratorWithIndex . html

Iterators are explained in Chapter 11, pdf-page 481 of
the SoftwareGuide:  http://www . itk . org/ItkSoftwareGuide . pdf


Regards,


    Luis




-----------------------
rg32 at njit . edu wrote:
> Thanks Luis,
> I had gone thru this code you pointed out , it can give bmp images as output 
> but has problems taking and reading a bmp image as input.Or am I missing 
> something?
> -Rashmi
> Quoting Luis Ibanez <luis . ibanez at kitware . com>:
> 
> 
>>Hi Rashmi,
>>
>>Please look at the  message posted by Marisa Aurelio:
>>
>>http://www . itk . org/pipermail/insight-users/2003-June/003952 . html
>>
>>It may be nice at some point to convert
>>this code into a "BMPImageIO" class.
>>
>>
>>Regards,
>>
>>
>>    Luis
>>
>>
>>---------------------------
>>rg32 at njit . edu wrote:
>>
>>
>>>Hello all,
>>>I'm trying to work with reading bmp images , processing them and again
>>
>>giving 
>>
>>>bmp images as output.ITK has no in-build bmp image readers /writers.Can
>>
>>anyone 
>>
>>>advise me as to how to proceed?
>>>Rashmi
>>>_______________________________________________
>>>Insight-users mailing list
>>>Insight-users at itk . org
>>>http://www . itk . org/mailman/listinfo/insight-users
>>>
>>> 
>>>
>>
>>
>>
>>
>>_______________________________________________
>>Insight-users mailing list
>>Insight-users at itk . org
>>http://www . itk . org/mailman/listinfo/insight-users
>>
> 
> 
>