program代写 This project adopts the object-oriented principle, slightly changed the Image class, and implemented a Manipulator class.
1.Description
This project adopts the object-oriented principle, slightly changed the Image class, and implemented a Manipulator class. The main functions are encapsulated in the class.program代写
The image read in the constructor is saved in the member variable “img_”, and all subsequent operations on this image generate a copy of this member variable and write it to a new file. When the program operates the picture, it does not affect other operations.
Class diagram is as follows.
2.Pseudocode
2.1 Show R/G/B channels
Image channel_filter(Image img, Channel channel): tmp_img = img for i from 0 to (tmp_img.w * tmp_ing.h): if channel == Red: tmp_img[i] *= kRed else if channel == Green: tmp_img[i] *= kGreen else if channel == Blue: tmp_img[i] *= kBlue return tmp_img
2.2 Change brightness
Image img_lighter(Image img, float light_rate): tmp_img = img for i from 0 to (tmp_img.w * tmp_ing.h): Rgb rate = Rgb(1 + light_rate, 1 + light_rate, 1 + light_rate) tmp_img[i] *= rate if (tmp_img[i].r > 1) tmp_img[i].r = 1; if (tmp_img[i].g > 1) tmp_img[i].g = 1; if (tmp_img[i].b > 1) tmp_img[i].b = 1; if (tmp_img[i].r < 0) tmp_img[i].r = 0; if (tmp_img[i].g < 0) tmp_img[i].g = 0; if (tmp_img[i].b < 0) tmp_img[i].b = 0; return tmp_img
3.Results
3.1 Select file
3.2 Show red channel
3.3 Show green channel
3.4 Show blue channel
3.5 Brightness increases by 0.2
3.6 Brightness decreases by 0.3
4.Analysis
This program basically implements the requirements mentioned in the documentation, but there are a few points that can be optimized. First, you can reimplement the Image class. Using C-style dynamic arrays as members of a class has drawbacks, especially when copying objects. Re-implementing it to the style of the stl template library avoids this inconvenience. In addition, the member variable property in the Image class is public, which does not conform to the encapsulation of the class. It is best to change its property to private and implement the get and set methods.program代写
更多其他:数据库代写 matlab代写 app代写 数学代写 CS代写 代写CS作业 数据分析代写 程序代写 程式代写 算法代写