首页 > 解决方案 > c++ Image Processing (cropping image from the cell)

问题描述

I have to do this: Crop the image from the cell (3, 3) and with the length and height 5 and 4 respectively.

I don't know what is meant by "crop the image from the cell," nor how to do it. I have an image stored in a 2D array with the height an length, looking like this:

imageArray[h][l]; //h = 8, l = 10.

Here is the image data that I have stored in a .txt file that I load into my 2D array:

0   255 255 255 0   0   255 255 255 0
255 0   255 255 0   0   255 255 0   255
255 255 0   255 255 255 255 0   255 255
255 255 255 0   255 255 0   255 255 255
255 255 255 255 0   0   255 255 255 255
255 255 255 255 0   0   255 255 255 255
255 255 255 0   255 255 0   255 255 255
0   0   0   255 255 255 255 0   0   0

标签: c++image

解决方案


crop
/kräp/
动词
动名词或现在分词:cropping
1. 剪短(某物,尤其是人的头发)非常短。
“她剪掉了长长的金色头发”

作业要求您将图像从 10x8 剪切为 5x4 图像。

他们还要求您删除左侧的前 3 行和顶部的前 3 列。

根据您的描述,我们无法判断您是否需要将要创建的图像放入新的二维数组中,或者您是否要将这些值写入文件,但我们知道您会想要将这些“像素”值复制到从位置 [3, 3] 到 [3+5, 3+4] 结束的某处。而且由于您知道从哪里开始(3),以及您将走多远(5 或 4),您将使用 for 循环。


推荐阅读