PPM Image Transformations

【信息科学与工程学】计算机科学与自动化 第二百三十三篇 凤凰架构01 编号类型领域系统软件/硬件或系统集成方案及系统架构模块子模块函数名称/算法名称算法的数学分析及计算机体系架构及数据结构与算法详细设计及参数列表及数值范围设计关联知识1共识算法分布式基石状态机复制架构:Proposer/Acceptor/Learner 多节点角色模型,基于操作转移(Operation Transfer)分布式共识PaxosPaxos 协议(Prepare/Promise/Accept/Accepted 两阶段)数学基础:多数派(Quorum)投票,基于鸽巢原理保证 W+R>N 时读写集合必有 阅读详情


PPM Image Transformations
Learning Objectives
Upon completion of this assignment, you should be able:
1. To develop, compile, run and test C programs in a Linux environment
2. To navigate Linux command lines reliably
The mechanisms you will practice using include:
 Linux command lines: manual pages, Linux commands
 C Programming: structs, pointers, memory allocation, getopt
Program Speciffcation
NAME
ppmcvt – convert ppm ffles
SYNOPSIS
ppmcvt [bg:i:r:smt:n:o:] ffle
DESCRIPTION
ppmcvt manipulates input Portable Pixel Map (PPM) ffles and outputs a new
image based on its given options. Only one option that speciffes a 
transformation can be used at a time.
In the synopsis, options followed by a ‘:’ expect a subsequent parameter. 
The options are:
-b
convert input ffle to a Portable Bitmap (PBM) ffle. (DEFAULT)
-g:
convert input ffle to a Portable Gray Map (PGM) ffle using the speciffed 
max grayscale pixel value [1-65535].
-i:
isolate the speciffed RGB channel. Valid channels are “red”, “green”, or
“blue”.
-r:
remove the speciffed RGB channel. Valid channels are “red”, “green”, 
or “blue”.
-s
apply a sepia transformation
-m
vertically mirror the ffrst half of the image to the second half
-t:
reduce the input image to a thumbnail based on the given scaling 
factor [1-8].
-n: tile thumbnails of the input image based on the given scaling factor [1-
8].
-o:
write output image to the speciffed ffle. Existent output ffles will be 
overwritten.
EXIT STATUS
ppmcvt exits 0 on success and 1 on failure.
EXAMPLES
ppmcvt -o out.pbm in.ppm
read in.ppm PPM ffle and write converted PBM ffle to out.pbm
ppmcvt -g 16 -o out.pgm in.ppm
convert the PPM image in.ppm to a PGM image in out.pgm
ppmcvt -s -o out.ppm in.ppm
apply a sepia transformation to the PPM image in in.ppm and output 
the new image to out.ppm
ppmcvt -n 4 -o out.ppm in.ppm
tile 4 1:4-scaled (quarter-sized) thumbnails of the image in in.ppm into 
a new PPPM image in out.ppm.
ERRORS
ppmcvt should print to the standard error output stream exactly the 
speciffed line and then exit under the following circumstances:
"Usage: ppmcvt [-bgirsmtno] [FILE]\n": malformed command line
"Error: Invalid channel speciffcation: (%s); should be 'red', 'green' or 'blue'\
n”
"Error: Invalid max grayscale pixel value: %s; must be less than 65,536\n"
"Error: Invalid scale factor: %d; must be 1-8\n"
"Error: No input ffle speciffed\n"
"Error: No output ffle speciffed\n"
"Error: Multiple transformations speciffed\n"
(File errors are handled for you by the provided pbm library.)Implementation and Submission Details
You must implement ppmcvt according to the speciffcations given above. You
are given skeleton ffles, ppmcvt.c and pbm_aux.c, in which to place your 
solution code. You may add helper functions to these ffles as you see fft.
You should do your testing from within you “priv” directory. 
- Create an empty subdirectory, and copy pbm.c, pbm.h, and Makefile 
from /home/cs350002/share/labs/lab0 to it.
- DO NOT ALTER those ffles
- copy Your ppmcvt.c and ppm_aux.c into that directory
- typing make should compile your ppmcvt for testing.
-you can test your ppmcvt against the reference ppmcvt provided.
There are some sample image ffles in the Image directory.
Start off with the small samples. You can also create your
own samples and even share with classmates.
When you are ready to submit create the lab0 subdirectory of cs350 
(ie /home/YOURID/cs350/lab0) and copy ONLY your ppmcvt.c and pbm_aux.c
there.
The PBM Library (partially provided)
The given PBM library (pbm.h and pbm.c) does the following:
1. Deffnes structs for PBM, PGM and PPM image types;
2. Deffnes I/O routines to read/write the images from/to PBM, PGM and 
PPM ffles.
a. (Note: The read routine does not handle image ffles with 
embedded comments.)
3. Declares memory allocation/deallocation routines for PBM, PGM and 
PPM structs.
a. You must implement these routines in pbm_aux.c.
Image File Formats
PPM, PGM and PBM ffles are simple (and inefffcient) ASCII text ffle image 
formats comprising a small header followed by integer values that represent 
each pixel in the image. Wikipedia has a good description here: 
https://en.wikipedia.org/wiki/Netpbm.
Image Transformations
Your program should produce exactly the same output images as mine. My 
program uses ffoating point arithmetic for all intermediate calculations then 
converts the resulting ffoats to integers as appropriate. 
Bitmap:
To compute black and white bits from RGB pixels use:Average( R+G+B)<PPMMax /2
Grayscale:
To compute grayscale pixels from RGB pixels use:
Average (R+G+B)
PPMMax
×PGMMax
Isolate:
For all pixels, set all but the speciffed “red”, “green” or “blue” channel to 
0.
Remove:
For all pixels, set the speciffed “red”, “green” or “blue” channel to 0.
Sepia:
For the sepia transformation, compute RGB pixels as follows:
NewR=0.393 (OldR)+0.769 (OldG)+0.189 x (OldB)
NewG=0.349 (OldR)+0.686 (OldG)+0.168 x (OldB)
NewB=0.272 (OldR)+0.534 (OldG)+0.131 x (OldB)
Mirror:
Vertically reffect the left half of the image onto the right half.
Thumbnail:
The height and width of the output thumbnail should be 1/n the height and
width of the original image, respectively, where n is the input scale factor. 
Shrink the input image simply by outputting every n
th
 pixel in both 
dimensions starting with the ffrst.
Nup:
Tile n 1/n scale thumbnails, where n is the input scale factor. The output 
image should be the same size of the input image.
Requirements and Constraints
This assignment aims to make you familiar with some ‘C’ programming 
basics. As such, we impose several requirements and constraints on your 
implementation:
1. You may not modify pbm.h nor pbm.c: you will not submit these ffles. 
We will compile your solutions using our original versions of these ffles.
2. You must use getopt() to process your program’s command line 
inputs.
3. You must use the provided pbm library (described below)
4. You may use only the following library or helper functions:
a. C Memory Allocation: malloc(), realloc(), calloc(), 
free()b. Command line parsing: getopt()
c. Other: fprintf(), strtol(), strcmp(), exit()
d. PBM library
5. Intermediate storage: You must use dynamically allocated memory to 
store any intermediary image data. That is, you may not create 
temporary image ffles nor use static arrays (for example, int 
image[MAXHEIGHT][MAXWIDTH]). Instead, you should create an array 
like: int **image and dynamically allocate the precise memory 
needed depending on the image size.
6. You must free dynamically allocated memory immediately when no 
longer needed.

【信息科学与工程学】计算机科学与自动化——第三百零五篇 数据中心 Scale-Up、Scale-Out、Scale-Across 20 GPU 训练中的各种算子融合技巧、梯度压缩与稀疏通信的高级变体、混合专家模型的负载均衡与通信优化、长序列模型的注意力机制优化、模型量化与蒸馏的联合优化、分布式训练中的容错与恢复、以及一些新兴硬件特性的建模(如 HBM3、GDDR7、CXL 3.0 内存语义、PCIe Gen6 PAM4 信令等)。每条仍然包含四个方程式子节。 阅读详情

相关推荐

SpringBoot+Vue+MySQL 高校学科竞赛平台 完整可运行版(源码+文档)

本项目基于SpringBoot+Vue+MySQL构建高校学科竞赛管理平台,覆盖学生、教师、领队教师、管理员四大角色,实现竞赛发布、报名、刷题、评分、公示等全流程闭环管理。系统架构清晰,技术主流,配套完整源码、数据库脚本、万字论文、开题报告、答辩PPT及部署文档,支持一键运行,适用于毕业设计、课程设计及院系二次开发,真正实现“开箱即用”。

招风的黑耳优快云 324

PPM和PSD图像格式

&lt;p&gt;&lt;strong&gt;PPM灰度文件:&lt;/strong&gt;&lt;/em&gt; &lt;p&gt;文件头由3行文本组成,可由fgets读出&lt;/p&gt; &lt;p&gt;1)第一行为“P2",表示文件类型&lt;/p&gt; &lt;p&gt;2)第二行为图像的宽度和高度&lt;/p&gt; &a

liu_kan的专栏 475

哈工大2024春大数据挖掘期末考试回忆版试题

(3)现有一个用户数量远多于物品(还是物品远多于用户,忘了是哪个了)的情景,应该使用基于user-user的推荐系统还是item-itmen的推荐系统,说明原因。(1)L是n*n拉普拉斯矩阵,x是一个n*1列向量,证明对任意的x,(x)^TLx>=0(6分)(3)证明:p到o的K-可达距离,至少是o的K-distance(2分)(2)(1)的结果说明竞争率的上界是多少?(2)考Gain的意义,如何利用Gain选择划分点(2分)(2)说明如何利用划分后的数据进行验证(2分)(2)k可达距离是对称的吗?

ymd2002的博客 1895

python 学习之 Pillow库

官方文档:https://pillow.readthedocs.io/en/3.3.x/handbook/tutorial.html#using-the-image-class The most important class in the Python Imaging Library is the Image class, defined in the module with th

sentimental_dog的博客 4481

Arduino创意作品实战案例:手把手教你做温控风扇

通过这个实用的arduino创意作品,轻松实现温度感应与风扇自动控制,结合传感器与编程逻辑,打造智能散热系统,是入门者理想的arduino创意作品实践项目。

weixin_42311427的博客 610

WSL Ubuntu20 通过1Panel配置SSH服务的完整避坑指南

本文详细介绍了在WSL Ubuntu20环境下通过1Panel配置SSH服务的完整指南,包括环境准备、SSH服务安装与基础配置、1Panel中的SSH管理技巧以及连接测试与故障排查。特别针对WSL特性提供了避坑建议,如IP动态变化处理、SSH服务初始化配置等关键步骤,帮助用户高效搭建稳定的SSH服务环境。

weixin_29239279的博客 415

【TensorFlow2.0】tf.keras.preprocessing.image.ImageDataGenerator#flow_from_diectory

flow_from_diectory是ImageGenerator类下的函数,从函数名,就可以明白其就是从文件夹中读取图像。 定义 def flow_from_directory(self, directory, target_size=(256, 256), color_mode='rgb', c

Accelerating的博客 659

开源Agent Skill让AI画图不再翻车:从数据到专业图表全流程

在人工智能与数据可视化交叉领域,让模型直接生成图表往往伴随字体乱码、坐标轴密集、配色失调等高频问题。Agent Skill作为一种可复用的能力封装机制,将专业绘图流程固化为标准化操作手册,从数据特征识别、图表类型决策到代码生成与渲染校验形成完整闭环。它不再依赖临时提示词的一次性发挥,而是让AI按领域专家的思维执行任务,显著提升出图质量与稳定性。这种能力在数据分析报告、运营日报、论文插图等场景具有广泛实用价值,尤其适用于需要快速产出规范化图表的工作流。本文即从这一技术范式出发,介绍一个GitHub上获得2.5

weixin_33851429的博客 1014

InnoDB 内存结构总览:Change Buffer、AHI 与 Log Buffer

本文系统梳理InnoDB内存结构中的ChangeBuffer、Adaptive Hash Index(AHI)与LogBuffer。ChangeBuffer缓存二级索引页不在内存时的变更,减少随机IO,仅在页加载时合并;聚簇索引修改立即执行,因数据本身不可延后。AHI基于高频等值查询自动构建哈希索引,加速定位,仅支持等值操作。LogBuffer为redo log内存缓冲,配合磁盘日志实现崩溃恢复。三者均服务于性能优化,其中ChangeBuffer与AHI共享BufferPool空间,而LogBuffer独立

bksczm的博客 309

数据分析案例-车辆二氧化碳排放量数据可视化分析

本实验数据集来源于Kaggle,该数据集捕获了车辆二氧化碳排放量随不同特征变化的详细信息。数据集取自加拿大政府官方开放数据网站。其中包含 7 年期间的数据。总共有 7385 行和 12 列。各列变量含义解释如下:Make:车辆的品牌或制造商。Model:车辆的具体车型名称。Vehicle Class:车辆的分类,如紧凑型、SUV等。Engine Size(L):车辆发动机的尺寸,以升为单位。Cylinders:车辆发动机的气缸数。

m0_64336780的博客 1万+

【Agent从入门到实践】40 容错优化:异常处理、重试机制、降级策略

各位小伙伴,咱们的多Agent框架一路优化到现在,决策快、执行效率高、资源用得省,看似啥都行,但只要一遇到网络波动、工具故障、数据异常调用web_search工具时网络超时,整个检索任务直接失败,写作Agent没数据可用向量库连接异常,向量检索直接崩掉,依赖检索结果的Agent全趴窝单个Agent执行出错,整个并行任务流程直接中断,前功尽弃高并发下部分工具调用失败,框架没有备用方案,只能返回任务失败说白了,咱们之前的框架只有正常执行逻辑,没有异常兜底逻辑。

人工智能AI技术 912

信创环境下PageOffice文档控件适配与实践

信创适配做到文档控件这一层,拼的已经不是"有没有国产版本",而是同一个功能在两类终端上是否真的等价。等价的标准很具体:同一次点击能得到同样的结果,同一份公文能得到同样的版式,同一个项目不需要维护两套代码。这背后是三件并不轻松的工作:服务端用一套接口同时支撑两类终端,客户端把两种系统与四种芯片的安装包分发清楚,文档内核层由产品侧跟着 WPS 的版本走。浏览器这一层的压力,则被收进了产品自己的窗口里——升级节奏由产品掌握,不再交给运气。

zi_wu_xian的专栏 336

【IoT】 产品设计之结构设计:如何设计产品按键

1、硅胶按键功能实现有两种接触方式 1)硅胶按键按压在DOME片(锅仔片)上 通常用在手机、儿童手表手机、防水手机等防水设备上。 2)硅胶按键增加导电基,一种黑色的导电碳粒,实现回路导电 通常用在遥控器、电脑键盘、特殊设备上。 两种方式结构设计原理是一样的,按键的固定与配合间隙与行程要确保好。 2、硅胶遥控器按键的结构方式(导电基) 按键帽为大颗粒实心的,触点为黑色导电基,通过压注成型融合为一体,那么这种按键结构设计时需要注意那些呢? 最主要的是按键按压回弹的手感,由于没有DOME片实现

产品线负责人 8675

第三篇 第 6 课

前置:第三篇第 1 课(stdx 引入),第二篇第 1 课(std.regex)。环境:仓颉 SDK 1.2.0。本文所有代码与输出均逐行实测。

weixin_41618057的博客 557

知识图谱实战应用8-从文本关系抽取到知识图谱关系构建流程贯通

大家好,我是微学AI,今天给大家介绍一下知识图谱实战应用8-从文本关系抽取到知识图谱关系构建流程贯通。我们从文本数据中采集到关键信息,并抽取出其中的关系信息,然后在存入图数据库中,整个过程实现自动化,我这里将举一个文本例子进行抽取。 对于知识图谱的构建是将实体、概念和它们之间的关系都以图表形式呈现出来的一种数据结构。要构建一个知识图谱,需要从不同的数据源中采集到相关信息,并将这些信息整合在一起,最终形成一个全面而且精确的知识图谱。

微学AI的博客 2545

lwip-2.0.3

lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。

【从零理解 Spring AI · 12】MCP 的两种角色:做客户端还是做服务端

上一篇讲了 MCP 的概念:标准协议、三大角色、M+N 替代 M×N。

nice_lcj520的博客 614

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

pcl2启动器下载(Minecraft PCL2 启动器 最新版 安装与使用说明)

摘要:PCL2(Plain Craft Launcher 2)是一款面向 Minecraft 的第三方启动器,支持正式版与快照版本管理、模组与整合包安装、Java 运行时自动匹配,绿色免安装、双击即可运行。适合在 Windows 上玩单机整合包、需要多版本共存或离线启动的用户使用

2611_96675819的博客 226

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

spring boot 4集成SQLLite,及其SQLLite的建库

spring boot 4集成SQLLite,及其SQLLite的建库

weixin_41463944的博客 231

Java 集合容器高频面试题全解:HashMap 树化阈值、1.7 死循环与 ConcurrentHashMap 演进(2026 招聘 JD 真题复盘)

HashMap 树化阈值 8 的泊松分布依据、退化阈值 6 的防抖设计、JDK 1.7 头插成环死循环的排查与修复、1.8 尾插后为何仍线程不安全、ConcurrentHashMap 放弃分段锁的原因与 ForwardingNode 协作扩容、computeIfAbsent 死锁陷阱、大集合找重复的场景题选型,附三层追问链自测。题目来源为 38 期公开招聘 JD 样本与字节、拼多多、建行、美团、快手公开面经。

蒙眼过河 427

spdlog 同步日志库使用详解

spdlog是一个轻量级 C++ 日志库,支持同步日志、异步日志、多线程日志、日志文件轮转和自定义日志格式。对于嵌入式 Linux 应用开发,我建议先使用。它可以帮我们完成:日志级别过滤。时间戳和线程 ID 输出。日志格式化。终端和文件输出。多线程安全写入。日志文件按大小或时间轮转。我们不需要自己实现互斥锁、文件写入、日志格式化和轮转等底层功能。

zengjiajun2006的博客 1124

JavaSE通关手册:数据类型与变量

代码无需额外处理,编译时编译器自动完成转换。

xys_678的博客 236

IDEA 简介:从零认识 IntelliJ IDEA

IDEA 全称,是由 JetBrains 公司开发的一款主流 Java 集成开发环境(IDE)。它集代码编辑、编译、调试、测试、版本控制、构建管理等功能于一体,被大量 Java 开发者视为日常开发的首选工具。所谓 IDE(Integrated Development Environment,集成开发环境),就是把写代码所需的各类工具整合到同一个界面中。相比只用文本编辑器加命令行编译,IDE 能显著减少重复操作,让开发者把精力集中在业务逻辑上。

ztI10的博客 185

Docker部署linkding:HTTPS与数据备份

部署私人书签库,除了让页面能够打开,还需要考虑几个实际问题:重建容器后数据是否保留、登录和保存是否正常、升级前怎样备份,以及出现 502 或 CSRF 错误时从哪里检查。本文使用 Docker Compose 部署 linkding,采用默认 SQLite 数据库,通过 Caddy 提供 HTTPS,并完成账户创建、数据持久化验证和备份。如果重建后账户或书签消失,应先检查是否换了项目目录、改了挂载路径,或者启动了另一套实例,不要急着重新初始化。遇到权限问题,应根据日志确认具体目录和运行用户,再调整权限。

tedcloud123的博客 194

C++20协程怎么运行?原理与三大核心组件深度剖析

C++20协程是轻量级的无栈状态机,通过co_await、co_yield、co_return实现挂起与恢复,由Promise、协程句柄和Awaitable三大组件协同工作。协程与线程互补,适用于高效管理大量并发I/O任务,显著降低上下文切换开销。其核心在于编译器生成的状态机机制,需配合库(如cppcoro)使用。掌握Promise控制逻辑、句柄生命周期管理及Awaitable语义,是构建高性能异步程序的基础。

Lucis__的博客 335

动态代理两大流派:JDK 代理与子类代理

业务类想加日志,最直白的写法是侵入式修改: 问题很明显:每个方法都要改一遍,改一个业务要动十处。代理模式的解法是:调用方不直接依赖 ,而是依赖一个代理对象。代理对象长得跟目标一模一样,调用它 → 代理先执行增强逻辑 → 再转调真实对象。 关键在于:代理对象的类型是哪来的?这就是"动态"二字的含义:代理类在运行时才诞生。两个角色: 承载增强逻辑, 负责生成代理类。 组装代理并调用: 输出: 业务代码 一行没动,增强逻辑全在 里。这就是 AOP 的味道。 内部四步: 第 2 步 内部:先查 (同一个接口

Android的专栏 661

c++ explicit关键字详解

explicit。

拒绝AI文,努力在AI时代写出感动人心的好文章 169
上一篇: CITS1401 Computational Thinking with Python
下一篇: CDS540 Text Detection from Images Using OpenCV
wx__codinghelp
博客等级 码龄2年 514粉丝 61原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值