MSc in Robotics
Programming Methods for Robotics Assignment
Irene Moulitsas & Peter Sherar
Cranfield University
Hand in date: 17/01/20 (FT), 31/01/20 (PT), 2:00pm
1. Introduction
In this assignment you are asked to write and test some C++ code for performing filtering operations
that can be applied to digital images. Some existing image handling code is made available to you
through Blackboard.
Background
Suppose we are given an image, and we can access each pixel in the natural way, that is, using two
coordinates [x, y] (row x, column y). Each pixel is a combination of three colours: Red, Green, and Blue,
each colour represented by an integer value from 0 to 255. (0 means complete absence of the colour,
255 means the colour participates with full intensity.)
For this assignment you are going to use a particular image format called ppm.
The ppm image format consists of a header followed by the image pixel data. The header contains the
following information:
1. A number which indicates the type of storage used for the pixel values of the image. If the
number is P3 it means that the pixel data is stored in ascii text format which is a seven bit
代写MSc留学生作业、Programming课程作业代
character code. Each byte of an ascii text file is interpreted as one ascii character.
If the number is P6 it means that the pixel data is stored in compressed binary format following
the header. Here all eight bits of each byte are used.
2. Optional comment which begins with the # tag.
3. Width, height and maximum colour value of the image (usually 255)
The pixel data that follows consists of RGB values in the range 0-maximum colour value
Example ppm file
The following data represents an ASCII ppm image for a 200 by 200 pixel red box:
P3
#RedBox.ppm
200 200
255
255 0 0 255 0 0 255 0 0 255 0 0 255 0 0 255 0 0 255 0 0 255 0 0 255 0 0 255 0 0
255 0 0 255 0 0 255 0 0 255 0 0 255 0 0 255 0 0 255 0 0 255 0 0 255 0 0 255 0 0
255 0 0 255 0 0 255 0 0 255 0 0 255 0 0 255 0 0 255 0 0 255 0 0 255 0 0 255 0 0
255 0 0 255 0 0 255 0 0 255 0 0 255 0 0 255 0 0 255 0 0 255 0 0 255 0 0 255 0 0
….
and so on for a total of 4,000 rows.
Applying a filter to an image
Suppose we want to "sharpen" an image. What we need to do is "pass a filter" over every pixel in the
image. For example, a sharpening filter could be the following:
To pass this filter over the image means the following: For every pixel [x, y] of the image consider first
its red-value component. This will be an integer between 0 and 255, as explained above -- call it R for
ease of reference. Now imagine that R is placed at the centre of the 3x3 filter shown above, i.e., at the
location of number 9. Multiply R by 9. Now do the same for each horizontal, vertical, and diagonal
neighbour of pixel [x, y], that is, take the pixel [x-1, y-1] and multiply its red-value component by -1
(because that is the value in the corresponding location in the filter); same for pixels [x, y-1], [x+1, y-
1], [x-1, y], and so on. Finally, sum up these nine products. The result is the red-value component of
the new ("filtered") pixel. Do the same for the green and blue components, and you have the whole
pixel of the new image. If the values are less than zero, you make them zero; and if they are over 255,
you make them 255. This procedure can be repeated for every pixel of the original image except the
ones at the very edge (first & last row, leftmost & rightmost column); you ignore those pixels and copy
them directly from the original image.
The three filtering operations relevant for the assignment are the following:
Smooth
Smoothing is an operation used to reduce noise within an image or to produce a less pixelated image. A filter
for smoothing an image is as follows:
Sharpen
Sharpening an image Increases contrast and accentuates detail in the image or selection, but may also
accentuate noise. The filter below uses appropriate weighting factors to replace each pixel with a weighted
average of the 3x3 neighbourhood:
0 1 0
1 0 1
0 1 0
-1 -1 -1
-1 9 -1
-1 -1 -1
Edge Detection
An edge detector highlights sharp changes in intensity in the active image or selection. Two 3x3 convolution
kernels (shown below) are used to generate vertical and horizontal derivatives. The final image is produced by
combining the two derivatives using the square root of the sum of the squares.
The final integer RGB values are computed by rounding the square root value obtained to the nearest
integer.
vertical filter horizontal filter

2. Tasks
You are provided with the following code:
1. A Pixel class with implementation for reading, writing, setting and getting, and a few other
operations on RGB values.
2. The following 3 image functions for reading, writing and converting ppm files in binary to
ascii format:
/* opens a binary ppm file for reading and opens an asci ppm file
for writing */
void openIOFiles(ifstream& fin, ofstream& fout,
char inputFilename[]);
/* converts a binary image data file to P3 ascii format */
void convertP6ToP3(ifstream& bin, ofstream& out,
vector<vector<Pixel> >& image, int info[1]);
/* write P3 header and image data to a file */
void writeP3Image(ofstream& out, vector<vector<Pixel> >& image,
char comment[], int maxColor);
There are also three helper functions used by the above image functions:
/* reads binary image data and writes asci image data (called from
convertP6ToP3) */
void readAndWriteImageData(ifstream& fin, ofstream& fout,
vector<vector<Pixel> >& image, int w, int h);
/* reads the header from a ppm file (called from convertP6ToP3) */
void readHeader(ifstream& fin, ofstream& fout, int imageInfo[]);
/* writes the header for a ppm file (called from readHeader and
writeP3Image) */
void writeHeader(ofstream& fout, char magicNumber[], char comment[],
int w, int h, int maxPixelVal);
The filtering functions to write are:
void smooth(vector<vector<Pixel> >& image);
void sharpen(vector<vector<Pixel> >& image);
void edgeDetection(vector<vector<Pixel> >& image);
Using the functions provided and the above filtering functions, you also need to write a main
function which should perform the following sequence of operations:
• Open the binary ppm image file
• Convert the binary file to P3 format
• Perform the filtering operation on the pixel data
• Write the P3 image file containing the filtered pixel values
Test your code on the images provided in Blackboard within the “images” folder.
3. Source Code and Report Requirements
The source program will need to compile on the IT lab machines using Visual Studio 2017 or 2019
without any other external dependencies/libraries/source codes of third parties. Alternatively, the
source program will need to compile on the IT lab machines Linux partition using the Intel compiler,
without any other external dependencies/libraries/source codes of third parties, and you will need to
include a README file with clear compilation and execution instructions.
Write a report to present and discuss your findings. The report should be no less than 2,000 words
and must not exceed 3,000 words. The report can contain any number of figures/tables, however all
figures/tables should be numbered and discussed. The report should include a description of your
implementation explaining the method used. The source code should be included as an Appendix to
the report.
4. Assignment Submission
The source code files should be submitted electronically via the Blackboard submission point by 2:00
pm on 17
th January (full-time students) or the 31st January (part-time students).
The report should be submitted electronically via the TurnItInUK submission point by the prescribed
deadline, for the assignment submission to be considered complete.
5. Marking
The assignment will be assessed based on the following marking scheme:
• 20% Introduction, methodology, conclusions
• 40% Source code, commenting
• 30% Analysis of the results
• 10% Report structure, presentation, references

因为专业,所以值得信赖。如有需要,请加QQ:99515681 或 微信:codehelp

MSc in Robotics的更多相关文章

  1. How to build the Robotics Library from source code on Windows

    The Robotics Library is an open source C++ library for robot kinematics, motion planning and control ...

  2. Coursera Robotics系列课心得

    Robotics Perception Professor Kostas and Jianbo Shi week 1: camera model 凸透镜成像原理:凸透镜焦点与焦距是固定的,这是物理性质 ...

  3. MMC不能打开文件D:\Program Files\Microsoft SQL Server\80\Tools\BINN\SQL Server Enterprise Manager.MSC

    以上问题的解决方式如下: 1. 打开windows运行对话框.在对话框输入mmc.打开了如图所示的控制台. 2. 文件---添加/删除管理单元(M). 3. 添加.然后选择Microsoft SQL ...

  4. Learning ROS for Robotics Programming - Second Edition(《学习ROS机器人编程-第二版》)

    Learning ROS for Robotics Programming - Second Edition <学习ROS机器人编程-第二版> ----Your one-stop guid ...

  5. Microsoft Robotics Developer Studio 4

    Microsoft Robotics Developer Studio 4       Share   Language: English   Download Microsoft® Robotics ...

  6. JBoss 系列九十六:JBoss MSC - 简介及一个简单演示样例

    什么是 JBoss MSC JBoss MSC 即 JBoss Modular Service Container,是第三代 JBoss 产品 JBoss 7和WildFfly的内核,JBoss MS ...

  7. windows中.msc文件详解

    msc是Microsoft Management Console的缩写.其实是一种可执行程序类型,可.exe类似.一般可以通过直接双击.msc文件或者在windows的运行中输入相应的文件名来启动. ...

  8. Oracle 数据的导入和导出(SID service.msc)

    一:版本号说明: (1)(Oracle11  32位系统)Oracle - OraDb11g_home1: (2)成功安装后显演示样例如以下:第一个图是管理工具.创建连接.创建表:第二个是数据库创建工 ...

  9. 2014 International Conference on Robotics and Computer Vision (ICRVC 2014)

    2014机器人与计算机视觉国际会议ICRVC 与会地点:北京 与会时间:2014.10.24-26 截稿日期:2014-07-10 关于征稿: 语言:英文 主题: • Evolutionary Rob ...

随机推荐

  1. canal使用

    报错信息:com.alibaba.druid.pool.DruidDataSource - testWhileIdle is true, validationQuery not set 解决方法: 找 ...

  2. C语言函数返回指针方法

    1.将函数内部定义的变量用static修饰 由于static修饰的变量,分配在静态内存区(类似于全局变量区),函数返回时,并不会释放内存,因此可以将要返回的变量加static修饰. int *test ...

  3. django 无限层级的评论

    一.摘要 拓展 django 官方的评论库,为评论提供无限层级的支持. 二.demo演示 访问链接: https://github.com/zmrenwu/django-mptt-comments 下 ...

  4. zookeeper+kafka集群的安装

    时效性要求很高的数据,库存,采取的是数据库+缓存双写的技术方案,也解决了双写的一致性的问题 缓存数据生产服务,监听一个消息队列,然后数据源服务(商品信息管理服务)发生了数据变更之后,就将数据变更的消息 ...

  5. js的splice和delete

    例如有一个数组是 :var textArr = ['a','b','c','d']; 这时我想删除这个数组中的b元素: 方法一:delete 删除数组 delete textArr[1]  结果为: ...

  6. TCP三次握手四次挥手介绍

    学过计算机网络的同学都知道TCP协议是计算机网络课程里面最复杂的协议之一,还没有通信就要搞个什么三次握手,断开还要什么四次分手,中间还要什么流量控制啦,拥塞控制,滑动窗口什么的,初学者看了就会头晕. ...

  7. aria2 cmd set chmod, and others..

    import 'package:flutter/material.dart'; import 'dart:io'; import 'dart:async'; import 'package:rxdar ...

  8. 《区块链DAPP开发入门、代码实现、场景应用》笔记5——区块链福利彩票的设计

    笔者一直强调,一定要利用区块链的特点来解决行业存在的问题,并且该问题最好用区块链解决或者说只能用区块链解决.彩票行业就是个例子. 在讲解代码之前,首先讲解一下业务设计,如图6.15所示. 图6.15 ...

  9. 快数据时代下,Moka携手DataPipeline提升招聘效能

    新时代下,招聘早已不再是过去被动式的流程管控行为,智能化的招聘技术被越来越多地运用到企业招聘中. 为能更好地帮助企业优化招聘渠道,提高招聘效率,提升雇主品牌,Moka从成立之初便秉承“简单”的逻辑,通 ...

  10. GO执行shell命令

    Golang执行shell命令主要依靠exec模块 代码为核心逻辑,并非全部 运行命令 cmd1 = exec.Command("ls") if err = cmd1.Run(); ...