был бы признателен за помощь в мозговом штурме для одного из моих заданий. Я должен написать программу, которая выполняет базовую обработку изображений .bmp. Программа откроет файл .bmp для чтения и записи и не изменит какую-либо часть заголовка, кроме значений пикселей в файле в соответствии с аргументами командной строки:
-fromrow x, where x specifies the bottommost row to process
-torowx, where x specifies the topmost row to process
-fromcol x, where x specifies the leftmost column to process
-tocol x, where x specifies the rightmost column to process
-op x, where x is one of the following:
- 1 = threshold the image (any pixel value in the specifies range over 127 is changed to 255, and pixel values 127 or less is changed to 0)
- 2 = negative (any pixel value p in the specified range is changed to 255-p)
To process image data, you will need to make use of the following:
- each pixel value is an unsigned char
- the number of rows in the image is stored as an int at position (byte address) 22 in the file
- the number of columns in the image is stored as an int at position (byte address) 18 in the file
- the position at which the pixel data starts is an int stored at position (byte address) 10 in the file
- pixel information is stored row by row, starting from the bottommost row in the image (row 0) and progressing upwards. within a row; pixel information is stored left to right. padding is added to the end of each row to make row length a multiple of 4 bytes (if the row has 479 columns, there is one extra padding at the end of the row before the next row starts)
Я немного растерялся относительно того, с чего начать, но я решил, что сначала мне нужно создать структурное растровое изображение, например, так?
struct bitmap {
unsigned int startrow;
unsigned int endrow;
unsigned int startcol;
unsigned int endcol;
}
Может ли кто-нибудь помочь мне объяснить, что мне нужно сделать для байтовых адресов, на которые ссылается это назначение? Любой другой совет мозгового штурма будет также высоко оценен. Спасибо!