You are to search a bitmap in rgb format and count the


The problem:

You are to search a bitmap in RGB format and count the number of pixels which match a set of colors. The bitmap will be 1024 by 1024 pixels for the purposes of explaining this problem. The set of colors will comprise 64 entries.

Input:

You shall process a file named CS546.bmp located in the C:\Temp directory. Note that your program will be tested with different sized bit maps. You will also receive a file containing the 64 colors, formatted as three integer values in the range of 0 to 255 (for red, green, and blue), along with a color name. The color name is a string which may contain spaces and apostrophes. For example:

79 105 198 Indigo
95 167 119 Forest Green
0 204 204 Robin's Egg Blue

This file will be named Colors64.txt and it will be located in the C:\Temp directory. You should assume that the number of colors in the file may vary. You should reject any input which has a negative value, or a value greater than 255 and display an appropriate message.

Processing:

1) Open the input files. End the program execution if either open fails. Initialize CPU time and storage usage measurements.

2.) Read the color file and construct an appropriate container. (For example, an array of structures would be appropriate here. CS532 students may substitute a more sophisticated method.) Initialize the color array (or whatever technique is used) with the contents of the color file. Include an integer count initialized to zero for each entry.

Read the bitmap array. For each pixel in the bitmap, determine if it matches one of the color entries. Maintain a count of the comparisons, matching or not. If it does, add one to the count associated with that entry. If it does not match any entries in the table, add one to a separate count of unmatched color entries.

Output

When all pixels in the bitmap have been evaluated, print out the color name and count of matches from the color array (or whatever other data structure you have chosen). Print the count of comparisons.

The following is the colors.txt file you may use for testing:

Apricot 253 213 177
Aquamarine 149 224 232
Bittersweet 254 111 94
Black 0 0 0
Blue 46 180 230
Blue-Gray 200 200 205
Blue-Green 0 149 183
Blue-Violet 100 86 183
Brick Red 198 45 66
Brown 175 89 62
Burnt Orange 255 112 52
Burnt Sienna 233 116 81
Cadet Blue 169 178 195
Carnation Pink 255 166 201
Copper 218 138 103
Cornflower 147 204 234
Forest Green 95 167 119
Gold 146 146 110
Goldenrod 252 214 103
Gray 139 134 128
Green 58 166 85
Green-Blue 40 135 200
Green-Yellow 241 231 136
Lavender 191 143 204
Lemon Yellow 255 255 159
Magenta 246 83 166
Mahogany 202 52 53
Maize 242 198 73
Maroon 195 33 72
Melon 254 186 173
Midnight Blue 0 70 140
Mulberry 200 80 155
Navy Blue 0 102 204
Olive Green 181 179 92
Orange 255 136 100
Orange-Red 255 63 52
Orange-Yellow 248 213 104
Orchid 226 156 210
Peach 255 203 164
Periwinkle 195 205 230
Pine Green 1 120 111
Plum 142 49 121
Raw Sienna 210 125 70
Raw Umber 102 82 51
Red 237 10 63
Red-Orange 255 104 31
Red-Violet 187 51 133
Salmon 255 145 164
Scarlet 253 14 53
Sea Green 147 223 184
Sepia 158 91 64
Silver 201 192 187
Sky Blue 118 215 234
Spring Green 236 235 189
Tan 217 154 108
Thistle 235 176 215
Turquoise Blue 108 218 231
Violet 115 46 108
Violet-Blue 118 110 200
Violet-Red 247 70 138
White 255 255 255
Yellow 252 232 131
Yellow-Green 197 225 122
Yellow-Orange 255 174 66

Request for Solution File

Ask an Expert for Answer!!
Computer Graphics: You are to search a bitmap in rgb format and count the
Reference No:- TGS02898588

Expected delivery within 24 Hours