Difference between revisions of "Aufgaben:Exercise 5.8: BMP Format"

From LNTwww
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
  
{{quiz-Header|Buchseite=Digitalsignalübertragung/Anwendungen bei Multimedia–Dateien
+
{{quiz-Header|Buchseite=Digital_Signal_Transmission/Applications_for_Multimedia_Files
 
}}
 
}}
  
[[File:P_ID1855__Dig_A_5_8a.png|right|frame|Foto "Sonnenuntergang"]]
+
[[File:P_ID1855__Dig_A_5_8a.png|right|frame|Photo "Sunset"]]
Ein Bitmap ist ein Bildformat, bei dem die einzelnen Pixel (von <i>Picture Elements</i>&nbsp;) in Matrixform abgespeichert werden. Der Header einer solchen BMP&ndash;Datei umfasst mindestens 54 Byte, bestehend aus dem Dateikopf (in Hexadezimaldarstellung von 0x00 bis 0x0D) sowie dem Informationsblock ab 0x0E. Anschließend folgen die Bilddaten, bei Farbbildern mit den Farbkomponenten R &ndash; G &ndash; B.
+
A bitmap is an image format in which the individual pixels (of <i>Picture Elements</i>&nbsp;) are stored in matrix form. The header of such a BMP file contains at least 54 bytes, consisting of the file header (in hexadecimal representation from 0x00 to 0x0D) as well as the information block starting from 0x0E. This is followed by the image data, in the case of color images with the color components R &ndash; G &ndash; B.
  
Der nachfolgende Hexdump beschreibt das Foto "Sunset.bmp". Dargestellt sind die ersten und letzten 96 der insgesamt 176456 Byte in Hexadezimaldarstellung.
+
The following hexdump describes the photo "Sunset.bmp". Shown are the first and last 96 of the total 176456 bytes in hexadecimal representation.
  
[[File:P_ID1857__Dig_A_5_8b_version2.png|center|frame|Hexdump zu Sunset.bmp]]
+
[[File:P_ID1857__Dig_A_5_8b_version2.png|center|frame|Hexdump for Sunset.bmp]]
Der '''Dateikopf''' beinhaltet folgende Informationen (der Präfix "0x" zeigt die Hexadezimaldarstellung an):
+
The '''file header''' contains the following information (the prefix "0x" indicates the hexadecimal representation):
* 0x00 ... 0x01 (2 Byte) BMP&ndash;Kennung: 0x 42 4D &nbsp;&#8658;&nbsp; "BM",
+
* 0x00 ... 0x01 (2 bytes) BMP identifier: 0x 42 4D &nbsp;&#8658;&nbsp; "BM",
* 0x02 ... 0x05 (4 Byte) Dateigröße in Byte,
+
* 0x02 ... 0x05 (4 bytes) file size in bytes,
* 0x06 ... 0x09 (5 Byte) reserviert (muss immer mit 0 belegt sein),
+
* 0x06 ... 0x09 (5 bytes) reserved (must always be assigned 0),
* 0x0A ... 0x0D (4 Byte) Offset (Beginn der Bilddaten).
+
* 0x0A ... 0x0D (4 bytes) offset (start of image data).
  
  
Diese Angaben gelten nur für den Intel&ndash;Prozessor, der nach der <i>Little&ndash;Endian&ndash;Byteanordnung</i> vom niederwertigsten (LSB) zum höchstwertigen (MSB) Byte liest. Die Anordnung "48 B1 02 00" der Bytes 2 bis 5 ist somit als "0x 00 02 B1 48" zu interpretieren, was der Dezimalzahl 176456 entspricht.
+
These specifications are only valid for the Intel processor, which reads according to the <i>little&ndash;endian byte order</i> from the least significant byte (LSB) to the most significant byte (MSB). The order "48 B1 02 00" of bytes 2 to 5 is therefore to be interpreted as "0x 00 02 B1 48", which corresponds to the decimal number 176456.
  
Der '''40 Byte&ndash;Informationsblock''' beinhaltet folgende Werte:
+
The '''40 byte information block''' contains the following values:
* 0x0E ... 0x11 (4 Byte) Länge des Info&ndash;Blocks,
+
* 0x0E ... 0x11 (4 bytes) length of the info block,
* 0x12 ... 0x15 (4 Byte) Bildbreite in Pixel,
+
* 0x12 ... 0x15 (4 bytes) image width in pixels,
* 0x16 ... 0x19 (4 Byte) Bildhöhe in Pixel,
+
* 0x16 ... 0x19 (4 bytes) image height in pixels,
* 0x1A ... 0x1B (2 Byte) Anzahl der Farbebenen (immer auf 1 gesetzt),
+
* 0x1A ... 0x1B (2 bytes) number of color planes (always set to 1),
* 0x1C ... 0x1D (2 Byte) Bits per Pixel (BPP),
+
* 0x1C ... 0x1D (2 bytes) bits per pixel (BPP),
* 0x1E ... 0x21 (4 Byte) Art der Datenkomprimierung,
+
* 0x1E ... 0x21 (4 bytes) type of data compression,
* 0x22 ... 0x25 (4 Byte) Größe der Bitmap in Byte,
+
* 0x22 ... 0x25 (4 bytes) size of the bitmap in bytes,
* 0x26 ... 0x29 (4 Byte) Horizontalauflösung in Pixel/Meter,
+
* 0x26 ... 0x29 (4 bytes) horizontal resolution in pixels/meter,
* 0x2A ... 0x2D (4 Byte) Vertikalauflösung in Pixel/Meter,
+
* 0x2A ... 0x2D (4 bytes) vertical resolution in pixels/meter,
* 0x2E ... 0x31 (4 Byte) Anzahl der verwendeten Farben,
+
* 0x2E ... 0x31 (4 bytes) number of colors used,
* 0x32 ... 0x35 (4 Byte) Anzahl der wichtigen Farben.
+
* 0x32 ... 0x35 (4 bytes) number of important colors.
  
  
Line 37: Line 37:
  
  
''Hinweis:''
+
''Note:''
* Die Aufgabe gehört zum Kapitel [[Digitalsignal%C3%BCbertragung/Anwendungen_bei_Multimedia%E2%80%93Dateien| Anwendungen bei Multimedia&ndash;Dateien]].
+
* The exercise belongs to the chapter [[Digital_Signal_Transmission/Applications_for_Multimedia_Files| "Applications for Multimedia Files"]].
 
   
 
   
  
  
===Fragebogen===
+
===Questions===
 
<quiz display=simple>
 
<quiz display=simple>
{Welches Bildformat hat das Bild "Sunset.bmp"?
+
{Which image format has the image "Sunset.bmp"?
 
|type="{}"}
 
|type="{}"}
$\rm Breite \ = \ $ { 280 } $\ \rm Pixel $
+
$\rm width \ = \ $ { 280 } $\ \rm pixels $
$\rm Höhe \hspace{0.3cm} = \ $ { 210 } $\ \rm Pixel $
+
$\rm height \hspace{0.3cm} = \ $ { 210 } $\ \rm pixels $
  
{Wie groß ist die Farbtiefe in "bit per pixel" $\rm (BPP)$?
+
{What is the color depth in "bit per pixel" $\rm (BPP)$?
 
|type="{}"}
 
|type="{}"}
$\rm Farbtiefe \ = \ $ { 24 } $\ \rm BPP $
+
$\rm color \ depth \ = \ $ { 24 } $\ \rm BPP $
  
{Wie groß ist die vertikale Auflösung in "dot per inch" $\rm (dpi)$? Umrechnung: $1 \ {\rm inch} \approx 25.4 \ \rm mm$?
+
{What is the vertical resolution in "dot per inch" $\rm (dpi)$? Conversion: $1 \ {\rm inch} \approx 25.4 \ \rm mm$?
 
|type="{}"}
 
|type="{}"}
$\rm vertikale \ Auflösung \ = \ $ { 97 3% } $\ \rm dpi $
+
$\rm vertical \ resolution \ = \ $ { 97 3% } $\ \rm dpi $
  
{Wieviele Byte &nbsp;$(N_{\rm Info})$&nbsp; umfasst hier der Informationsblock? Ab welchem Byte &nbsp;$\rm (Offset)$&nbsp; beginnen die Bilddaten?
+
{How many bytes &nbsp;$(N_{\rm Info})$&nbsp; does the information block contain here? From which byte &nbsp;$\rm (offset)$&nbsp; does the image data start?
 
|type="{}"}
 
|type="{}"}
$\rm Offset \ = \ $ { 54 } $\ \rm Byte $
+
$\rm offset \ = \ $ { 54 } $\ \rm bytes $
$N_{\rm Info}  \hspace{0.38cm} = \ $ { 176402 1% } $\ \rm (dezimal) $
+
$N_{\rm Info}  \hspace{0.38cm} = \ $ { 176402 1% } $\ \rm (decimal) $
  
{Wie lauten die Dezimalwerte der Farbkomponenten des linken oberen Pixels?
+
{What are the decimal values of the color components of the upper left pixel?
 
|type="{}"}
 
|type="{}"}
$R \ = \ $ { 40 } $\ \rm (dezimal) $
+
$R \ = \ $ { 40 } $\ \rm (decimal) $
$G \ = \ $ { 82 } $\ \rm (dezimal) $
+
$G \ = \ $ { 82 } $\ \rm (decimal) $
$B \ = \ $ { 115 } $\ \rm (dezimal) $
+
$B \ = \ $ { 115 } $\ \rm (decimal) $
 
</quiz>
 
</quiz>
  
  
===Musterlösung===
+
===Solution===
 
{{ML-Kopf}}
 
{{ML-Kopf}}
'''(1)'''&nbsp; Die Bildbreite (im Bereich 0x12 ... 0x15) hat den Hexadezimalwert 0x118 (Dezimalwert 280).  
+
'''(1)'''&nbsp; The image width (in the range 0x12 ... 0x15) has the hexadecimal value 0x118 (decimal value 280).  
*Entsprechend hat die Bildhöhe (im Bereich 0x16 ... 0x19) den Hexadezimalwert 0x00D2 &#8658; 210 Pixel.  
+
*Correspondingly, the image height (in the range 0x16 ... 0x19) has the hexadecimal value 0x00D2 &#8658; 210 pixels.
*Einzugeben sind jeweils die Dezimalwerte <u>280</u> (Breite) und <u>210</u> (Höhe).
+
*The decimal values <u>280</u> (width) and <u>210</u> (height) are to be entered in each case.
  
  
'''(2)'''&nbsp; Die Farbtiefe beträgt <u>24 BPP</u> (hexadezimal 0x18), wie im Bereich 0x1C ... 0x1D angegeben.
+
'''(2)'''&nbsp; The color depth is <u>24 BPP</u> (hexadecimal 0x18), as specified in the range 0x1C ... 0x1D.
  
  
  
'''(3)'''&nbsp; Die vertikale Auflösung findet man im Bereich 0x2A ... 0x2D. Sie beträgt 0x 0E EA = 3818 Pixel pro Meter.  
+
'''(3)'''&nbsp; The vertical resolution can be found in the range 0x2A ... 0x2D. It is 0x 0E EA = 3818 pixels per meter.
*Mit der angegebenen Längenumrechnung ergibt sich daraus 3818 &middot; 0.0254 <u>&asymp; 97 dpi</u> (dots per inch).  
+
*With the specified length conversion, this results in 3818 &middot; 0.0254 <u>&asymp; 97 dpi</u> (dots per inch).  
*Die horizontale Auflösung (Bereich 0x26 ... 0x29) ist ähnlich, aber nicht gleich: 0x0EC3 &#8658; 3779 &middot; 0.0254 &asymp; 96 dpi.
+
*The horizontal resolution (range 0x26 ... 0x29) is similar, but not the same: 0x0EC3 &#8658; 3779 &middot; 0.0254 &asymp; 96 dpi.
  
  
  
'''(4)'''&nbsp; Bei 24 BPP (Farbtiefe) hat der Informationsblock die minimale Größe 0x28 = 40d, da dann keine Farbinformation in Tabellenform angegeben wird.  
+
'''(4)'''&nbsp; At 24 BPP (color depth) the information block has the minimum size 0x28 = 40d, because then no color information is given in tabular form.
*Der Offset beträgt unter Berücksichtigung der 14 Byte für den Dateiheader 0x36 <u>= 54 Byte</u> (Offset). Das erste Datenbyte liegt somit bei 0x36.
+
*Taking into account the 14 bytes for the file header, the offset is 0x36 <u>= 54 bytes</u> (offset). The first data byte is therefore 0x36.
  
*Die Größe der Bitmap (im Bereich 0x22 ... 0x25) beträgt 0x 02 B1 12 = 176402d. Dieser Wert ist um <u>54</u> (Dateikopf) kleiner als die Dateigröße. Dieser Wert setzt sich wie folgt zusammen:
+
*The size of the bitmap (in the range 0x22 ... 0x25) is 0x 02 B1 12 = 176402d. This value is smaller than the file size by <u>54</u> (file header). This value is composed as follows:
 
:$$N_{\rm Info}  = 280 \cdot 210 \cdot 3 + 2 \hspace{0.15cm}\underline {= 176402} .$$
 
:$$N_{\rm Info}  = 280 \cdot 210 \cdot 3 + 2 \hspace{0.15cm}\underline {= 176402} .$$
  
*Hierbei berücksichtigt die "2" die beiden Abschlussbytes (00 00), wie aus dem Hexdump auf der Angabenseite zu ersehen ist.
+
*Here, the "2" takes into account the two termination bytes (00 00), as can be seen from the hex dump in the information section.
  
  
'''(5)'''&nbsp; Die Bilddaten werden zeilenweise von rechts unten nach links oben mit jeweils drei Byte abgespeichert. Die Farbwerte des linken oberen Punktes sind somit
+
'''(5)'''&nbsp; The image data are stored line by line from bottom right to top left with three bytes each. The color values of the upper left point are thus
 
:: <i>R</i> = 0x28 <u>= 40d</u>,
 
:: <i>R</i> = 0x28 <u>= 40d</u>,
 
:: <i>G</i> = 0x52 <u>= 82d</u>,
 
:: <i>G</i> = 0x52 <u>= 82d</u>,
Line 102: Line 102:
  
  
Beachten Sie hierbei wieder die <i>Little&ndash;Endian&ndash;Byteanordnung</i> des Intelprozessors, so dass &nbsp;"R &ndash; G &ndash; B"&nbsp; tatsächlich in der Reihen &nbsp;"B &ndash; G &ndash; R"&nbsp; angeordnet werden.
+
Note here again the <i>little&ndash;endian byte order</i> of the Intel processor, so that &nbsp;"R &ndash; G &ndash; B"&nbsp; are actually arranged in the rows &nbsp;"B &ndash; G &ndash; R".&nbsp;  
 
{{ML-Fuß}}
 
{{ML-Fuß}}
  
  
  
[[Category:Digital Signal Transmission: Exercises|^5.4 Multimedia-Dateien^]]
+
[[Category:Digital Signal Transmission: Exercises|^5.4 Multimedia Files^]]

Latest revision as of 13:46, 18 October 2022

Photo "Sunset"

A bitmap is an image format in which the individual pixels (of Picture Elements ) are stored in matrix form. The header of such a BMP file contains at least 54 bytes, consisting of the file header (in hexadecimal representation from 0x00 to 0x0D) as well as the information block starting from 0x0E. This is followed by the image data, in the case of color images with the color components R – G – B.

The following hexdump describes the photo "Sunset.bmp". Shown are the first and last 96 of the total 176456 bytes in hexadecimal representation.

Hexdump for Sunset.bmp

The file header contains the following information (the prefix "0x" indicates the hexadecimal representation):

  • 0x00 ... 0x01 (2 bytes) BMP identifier: 0x 42 4D  ⇒  "BM",
  • 0x02 ... 0x05 (4 bytes) file size in bytes,
  • 0x06 ... 0x09 (5 bytes) reserved (must always be assigned 0),
  • 0x0A ... 0x0D (4 bytes) offset (start of image data).


These specifications are only valid for the Intel processor, which reads according to the little–endian byte order from the least significant byte (LSB) to the most significant byte (MSB). The order "48 B1 02 00" of bytes 2 to 5 is therefore to be interpreted as "0x 00 02 B1 48", which corresponds to the decimal number 176456.

The 40 byte information block contains the following values:

  • 0x0E ... 0x11 (4 bytes) length of the info block,
  • 0x12 ... 0x15 (4 bytes) image width in pixels,
  • 0x16 ... 0x19 (4 bytes) image height in pixels,
  • 0x1A ... 0x1B (2 bytes) number of color planes (always set to 1),
  • 0x1C ... 0x1D (2 bytes) bits per pixel (BPP),
  • 0x1E ... 0x21 (4 bytes) type of data compression,
  • 0x22 ... 0x25 (4 bytes) size of the bitmap in bytes,
  • 0x26 ... 0x29 (4 bytes) horizontal resolution in pixels/meter,
  • 0x2A ... 0x2D (4 bytes) vertical resolution in pixels/meter,
  • 0x2E ... 0x31 (4 bytes) number of colors used,
  • 0x32 ... 0x35 (4 bytes) number of important colors.




Note:


Questions

1

Which image format has the image "Sunset.bmp"?

$\rm width \ = \ $

$\ \rm pixels $
$\rm height \hspace{0.3cm} = \ $

$\ \rm pixels $

2

What is the color depth in "bit per pixel" $\rm (BPP)$?

$\rm color \ depth \ = \ $

$\ \rm BPP $

3

What is the vertical resolution in "dot per inch" $\rm (dpi)$? Conversion: $1 \ {\rm inch} \approx 25.4 \ \rm mm$?

$\rm vertical \ resolution \ = \ $

$\ \rm dpi $

4

How many bytes  $(N_{\rm Info})$  does the information block contain here? From which byte  $\rm (offset)$  does the image data start?

$\rm offset \ = \ $

$\ \rm bytes $
$N_{\rm Info} \hspace{0.38cm} = \ $

$\ \rm (decimal) $

5

What are the decimal values of the color components of the upper left pixel?

$R \ = \ $

$\ \rm (decimal) $
$G \ = \ $

$\ \rm (decimal) $
$B \ = \ $

$\ \rm (decimal) $


Solution

(1)  The image width (in the range 0x12 ... 0x15) has the hexadecimal value 0x118 (decimal value 280).

  • Correspondingly, the image height (in the range 0x16 ... 0x19) has the hexadecimal value 0x00D2 ⇒ 210 pixels.
  • The decimal values 280 (width) and 210 (height) are to be entered in each case.


(2)  The color depth is 24 BPP (hexadecimal 0x18), as specified in the range 0x1C ... 0x1D.


(3)  The vertical resolution can be found in the range 0x2A ... 0x2D. It is 0x 0E EA = 3818 pixels per meter.

  • With the specified length conversion, this results in 3818 · 0.0254 ≈ 97 dpi (dots per inch).
  • The horizontal resolution (range 0x26 ... 0x29) is similar, but not the same: 0x0EC3 ⇒ 3779 · 0.0254 ≈ 96 dpi.


(4)  At 24 BPP (color depth) the information block has the minimum size 0x28 = 40d, because then no color information is given in tabular form.

  • Taking into account the 14 bytes for the file header, the offset is 0x36 = 54 bytes (offset). The first data byte is therefore 0x36.
  • The size of the bitmap (in the range 0x22 ... 0x25) is 0x 02 B1 12 = 176402d. This value is smaller than the file size by 54 (file header). This value is composed as follows:
$$N_{\rm Info} = 280 \cdot 210 \cdot 3 + 2 \hspace{0.15cm}\underline {= 176402} .$$
  • Here, the "2" takes into account the two termination bytes (00 00), as can be seen from the hex dump in the information section.


(5)  The image data are stored line by line from bottom right to top left with three bytes each. The color values of the upper left point are thus

R = 0x28 = 40d,
G = 0x52 = 82d,
B = 0x73 = 115d.


Note here again the little–endian byte order of the Intel processor, so that  "R – G – B"  are actually arranged in the rows  "B – G – R".