c++ - 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
解决方案
crop
/kräp/
动词
动名词或现在分词:cropping
1. 剪短(某物,尤其是人的头发)非常短。
“她剪掉了长长的金色头发”
作业要求您将图像从 10x8 剪切为 5x4 图像。
他们还要求您删除左侧的前 3 行和顶部的前 3 列。
根据您的描述,我们无法判断您是否需要将要创建的图像放入新的二维数组中,或者您是否要将这些值写入文件,但我们知道您会想要将这些“像素”值复制到从位置 [3, 3] 到 [3+5, 3+4] 结束的某处。而且由于您知道从哪里开始(3),以及您将走多远(5 或 4),您将使用 for 循环。
推荐阅读
- python-3.x - 在 Jupyter Lab 上使用 SAP STI(官方教程),得到“无法反序列化关键数据”
- javascript - 交叉点观察者不读取页面加载后添加的新元素或条目
- swift - Swift 结构化并发中是否有 Thread.threadDictionary 的等价物?
- python - 如何将图像从 URL 传递到 Django 模板?
- rabbitmq - 绑定是否需要将参数/设置与 Spring RabbitMQ 中的队列匹配?
- python - 尝试在 Windows 10 中的 ubuntu 上导入隐藏库时出现导入错误
- shopify - 选择变化时如何更新数量字段 Shopify
- ssis - 安装 VS 2022 时 VS2019 SSIS 包主题损坏
- sql-server - 即使值不匹配,两个表中的列总和?
- php - 如何正确报告 Laravel 8.x 中的自定义异常?