Using C++, write a program to perform operations on 'images'. An 'image' is a two-dimensional array of characters. 7 )`-
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
Using C++, write a program to perform operations on 'images'. An 'image' is a two-dimensional array of characters. 7 )`-
2. Loading an Image from a File Your program should provide a function similar to the following to read images from a text file: Dimension loadImage (char image[][100], char filename[]) This function should first initialize the image passed as a parameter with space characters (). It should then open the filename passed as a parameter and read each line of the file and store it as a row in the image. The getline function could be used to read the file one line at a time. Since the lines have different numbers of characters, the maximum number of characters in any line must be found. This should be stored in the width field of a Dimension variable. The number of lines in the image should be stored in the height field. When all the lines have been read from the file and copied to the 2-D array, the Dimension variable is returned by the function. 3. Displaying an Image Your program should provide a function similar to the following to display an image in memory on the monitor: void displayimage (char image[][100], Dimension d) 4. Copying an Image Your program should provide a function similar to the following to copy an image in memory to another image: void copylmage (char imageCopy[][100], char image[][100], Dimension d)
5. Join Images Horizontally Your program should provide a function similar to the following to join two images horizontally and store the new image in the image1 parameter. The contents of image2 should be to the right of the original contents of image1 after the join operation. Dimension joinimagesHoriz (char image1[][100], Dimension d1, char image2[][100], Dimension d2) D_ ITIL- - / - / - \((( @@) / 22 D ( 17 || \\, |--L (CC Figure 3: Two Images Joined Horizontally Together
6. Join Images Vertically Your program should provide a function similar to the following to join two images vertically and store the new image in the image1 parameter. The contents of image2 should be at the bottom of the original contents of image1 after the join operation. Dimension joinimagesVert (char image1[][100], Dimension d1, char image2[][100], Dimension d2) ...--20 )'-') \((""" TIL 1__1 \_T_-_((. 11, / || |--L ( Figure 4: Two Images Joined Vertically Together
8. Flip Horizontally Your program should provide a function similar to the following to flip an image horizontally. void fliplmageHoriz (char image[][100], Dimension d) Figure 5 shows two images joined horizontally together where the second image is a horizontal flip of the first image (a copy of the original image was made before the flip operation). NB: SA /)-))-) / \((((\ .'7/1 I |/ 7'. T Figure 5: An Image Flipped Horizontally Because characters are used to create the images, the flip operation does not result in a perfect flip of the original image.
TIL-/ Og سکتا TIL 63 Sile- )`-') Process exited after 6.432 seconds with return value e Press any key to continue
S (>@ @ ))) °℃.((()) Innh Process exited after 8.239 seconds with return value e Press any key to continue.