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

From LNTwww
 
(23 intermediate revisions by 5 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>) 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 &bdquo;Sunset.bmp&rdquo;. 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 <font color="#cc0000"><span style="font-weight: bold;">Dateikopf</span></font> 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; &bdquo;BM&rdquo;,
+
* 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, 3, 4 und 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 <font color="#990000"><span style="font-weight: bold;">40 Byte&ndash;Informationsblock</span></font> 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.
  
  
''Hinweis:''
 
* Die Aufgabe gehört zum Themengebiet des Kapitels [[Digitalsignal%C3%BCbertragung/Anwendungen_bei_Multimedia%E2%80%93Dateien| Anwendungen bei Multimedia&ndash;Dateien]].
 
  
  
===Fragebogen===
+
 
 +
 
 +
 
 +
''Note:''
 +
* The exercise belongs to the chapter [[Digital_Signal_Transmission/Applications_for_Multimedia_Files| "Applications for Multimedia Files"]].
 +
 +
 
 +
 
 +
===Questions===
 
<quiz display=simple>
 
<quiz display=simple>
{Welches Bildformat hat das Bild &bdquo;Sunset.bmp&rdquo;?
+
{Which image format has the image "Sunset.bmp"?
 
|type="{}"}
 
|type="{}"}
$\rm Breite \ = \ $ { 280 3% } $\ \rm Pixel $
+
$\rm width \ = \ $ { 280 } $\ \rm pixels $
$\rm Höhe \ = \ $ { 210 3% } $\ \rm Pixel $
+
$\rm height \hspace{0.3cm} = \ $ { 210 } $\ \rm pixels $
  
{Wie groß ist die Farbtiefe in BPP (bit per pixel)?
+
{What is the color depth in "bit per pixel" $\rm (BPP)$?
 
|type="{}"}
 
|type="{}"}
$\rm Farbtiefe \ = \ $ { 24 3% } $\ \rm BPP $
+
$\rm color \ depth \ = \ $ { 24 } $\ \rm BPP $
  
{Wie groß ist die vertikale Auflösung in dpi (dot per inch); $1 \ {\rm inch} = 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 ($N_{\rm Info}$) umfasst hier der Informationsblock? Ab welchem Byte (Offset) 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="{}"}
$N_{\rm Info} \ = \ $ { 176402 3% } $\ \rm (dezimal) $
+
$\rm offset \ = \ $ { 54 } $\ \rm bytes $
$\rm Offset \ = \ $ { 54 3% } $\ \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 3% } $\ \rm (dezimal) $
+
$R \ = \ $ { 40 } $\ \rm (decimal) $
$G \ = \ $ { 823% } $\ \rm (dezimal) $
+
$G \ = \ $ { 82 } $\ \rm (decimal) $
$B \ = \ $ { 115 3% } $\ \rm (dezimal) $
+
$B \ = \ $ { 115 } $\ \rm (decimal) $
 
</quiz>
 
</quiz>
  
  
===Musterlösung===
+
===Solution===
 
{{ML-Kopf}}
 
{{ML-Kopf}}
'''(1)'''&nbsp;  
+
'''(1)'''&nbsp; The image width (in the range 0x12 ... 0x15) has the hexadecimal value 0x118 (decimal value 280).
'''(2)'''&nbsp;  
+
*Correspondingly, the image height (in the range 0x16 ... 0x19) has the hexadecimal value 0x00D2 &#8658; 210 pixels.
'''(3)'''&nbsp;  
+
*The decimal values <u>280</u> (width) and <u>210</u> (height) are to be entered in each case.
'''(4)'''&nbsp;  
+
 
'''(5)'''&nbsp;  
+
 
'''(6)'''&nbsp;
+
'''(2)'''&nbsp; The color depth is <u>24 BPP</u> (hexadecimal 0x18), as specified in the range 0x1C ... 0x1D.
 +
 
 +
 
 +
 
 +
'''(3)'''&nbsp; 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 &middot; 0.0254 <u>&asymp; 97 dpi</u> (dots per inch).
 +
*The horizontal resolution (range 0x26 ... 0x29) is similar, but not the same: 0x0EC3 &#8658; 3779 &middot; 0.0254 &asymp; 96 dpi.
 +
 
 +
 
 +
 
 +
'''(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.
 +
*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.
 +
 
 +
*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} .$$
 +
 
 +
*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; 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>G</i> = 0x52 <u>= 82d</u>,
 +
:: <i>B</i> = 0x73 <u>= 115d</u>.
 +
 
 +
 
 +
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:Aufgaben zu Digitalsignalübertragung|^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".