SlideShare a Scribd company logo
1 of 10
Homework#7 
Problem 2 補充教學 
Computer Programming, Fall 2014, Taipei Tech EECS 
1
題目要求 
180° 
Computer Programming, Fall 2014, Taipei Tech EECS 
2
小提醒 
• PPM檔windows沒有內建打得開的軟體喔~ 
• 老師的PDF有可以打開PPM檔的程式連結 
• IrfanView免安裝任意門: 
• http://www.azofreeware.com/2012/03/irfanview-432.html 
Computer Programming, Fall 2014, Taipei Tech EECS 
3
什麼是PPM? 
• 不是化學濃度單位XD 
• PPM是一種圖片格式,常見類型為24位RGB二進制保存 
Computer Programming, Fall 2014, Taipei Tech EECS 
4
PPM(Portable PixMap) 
• PPM,其實就是把每一個點的RGB分別保存起來。所以,PPM格式的 
文件是沒有壓縮的,相對比較大,但是由於圖片格式簡單,一般作為圖 
片處理的中間文件(不會丟失文件信息),或者作為簡單的圖片格式保 
存。 
Computer Programming, Fall 2014, Taipei Tech EECS 
5
PPM格式分析 
• 第一部分是文件magic number 
• 第二部分是圖像寬度和高度(空格隔開) 
• 第三部分是描述像素的最大顏色組成(0-255) 
Computer Programming, Fall 2014, Taipei Tech EECS 
6
255 0 0 0 255 0 0 0 255 
255 255 0 255 255 255 0 0 0 
0 1 2 
0 
1 
Array長這樣: (unsigned char array[2*3*3] ) 
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 
255 0 0 0 255 0 0 0 255 255 255 0 255 255 255 0 0 0 
所以當我要抓第2行第1個(1, 0)像素=> array[1*3*3] 
抓座標在(x, y)的像素=> array[(x*圖片寬度+y)*3] 
Computer Programming, Fall 2014, Taipei Tech EECS 7
string.h memmove() 
• 以下程式從字元陣列t 拷貝6 個字元替換字元 
陣列s 前端的6 個字元 
• #include <stdio.h> 
• #include <string.h> 
• int main(void) 
• { 
• char s[20] = "out of work"; 
• char t[20] = "future"; 
• memmove(s, t, 6); 
• printf("%sn", s); 
• return 0; 
• } 
Computer Programming, Fall 2014, Taipei Tech EECS 8
temp = (unsigned char *)malloc(w*h*3); 
for(i = 0;i < h/2;i++) 
{ 
memmove(temp, &image[i*w*3], sizeof(unsigned char)*w*3); 
memmove(&image[i*w*3], &image[(h-i-1)*w*3], sizeof(unsigned char)*w*3); 
memmove(&image[(h-i-1)*w*3], temp, sizeof(unsigned char)*w*3); 
} 
水平 
鏡像 
Computer Programming, Fall 2014, Taipei Tech EECS 9
• 可是題目要的是旋轉180°欸…… 
• 水平鏡像翻轉之後再做垂直鏡像翻轉就成功啦~~~ 
Computer Programming, Fall 2014, Taipei Tech EECS 
10

More Related Content

What's hot (16)

Python p.193 197
Python p.193 197Python p.193 197
Python p.193 197
 
Ppt 136-136
Ppt 136-136Ppt 136-136
Ppt 136-136
 
Ppt 1-50
Ppt 1-50Ppt 1-50
Ppt 1-50
 
Ppt 51-77
Ppt 51-77Ppt 51-77
Ppt 51-77
 
Sym py edu
Sym py eduSym py edu
Sym py edu
 
Python9-3
Python9-3Python9-3
Python9-3
 
Ppt 120-126
Ppt 120-126Ppt 120-126
Ppt 120-126
 
Taylor example
Taylor exampleTaylor example
Taylor example
 
Ppt 127-135
Ppt 127-135Ppt 127-135
Ppt 127-135
 
Ppt 78-100
Ppt 78-100Ppt 78-100
Ppt 78-100
 
Ppt 138-142
Ppt 138-142Ppt 138-142
Ppt 138-142
 
Tcl tk_科技啟蒙
Tcl tk_科技啟蒙Tcl tk_科技啟蒙
Tcl tk_科技啟蒙
 
Ch2 習題
Ch2 習題Ch2 習題
Ch2 習題
 
Ch4 習題
Ch4 習題Ch4 習題
Ch4 習題
 
Ch2 教學
Ch2 教學Ch2 教學
Ch2 教學
 
Photoshop 的色階與曲線調整 Levels and curve Adjustment in Photoshop
Photoshop 的色階與曲線調整 Levels and curve Adjustment in Photoshop Photoshop 的色階與曲線調整 Levels and curve Adjustment in Photoshop
Photoshop 的色階與曲線調整 Levels and curve Adjustment in Photoshop
 

Similar to Homework7補充教學

Python匯出入csv以及繪製圖表初稿
Python匯出入csv以及繪製圖表初稿Python匯出入csv以及繪製圖表初稿
Python匯出入csv以及繪製圖表初稿jiannrong
 
Python 于 webgame 的应用
Python 于 webgame 的应用Python 于 webgame 的应用
Python 于 webgame 的应用勇浩 赖
 
基于嵌入式系统的Avs P10编码系统设计
基于嵌入式系统的Avs P10编码系统设计基于嵌入式系统的Avs P10编码系统设计
基于嵌入式系统的Avs P10编码系统设计Hengyi
 
教青少年寫程式
教青少年寫程式教青少年寫程式
教青少年寫程式Renyuan Lyu
 
數位出版2.0 it
數位出版2.0 it數位出版2.0 it
數位出版2.0 it志賢 黃
 
給軟體工程師的不廢話 R 語言精要班
給軟體工程師的不廢話 R 語言精要班給軟體工程師的不廢話 R 語言精要班
給軟體工程師的不廢話 R 語言精要班台灣資料科學年會
 
MapReduce 簡單介紹與練習
MapReduce 簡單介紹與練習MapReduce 簡單介紹與練習
MapReduce 簡單介紹與練習孜羲 顏
 
漫談 Source Control Management
漫談 Source Control Management漫談 Source Control Management
漫談 Source Control ManagementWen-Shih Chao
 
Learning python in the motion picture industry by will zhou
Learning python in the motion picture industry   by will zhouLearning python in the motion picture industry   by will zhou
Learning python in the motion picture industry by will zhouWill Zhou
 
R統計軟體 -安裝與使用
R統計軟體 -安裝與使用R統計軟體 -安裝與使用
R統計軟體 -安裝與使用Person Lin
 
程式人雜誌 -- 2013年5月號
程式人雜誌 -- 2013年5月號程式人雜誌 -- 2013年5月號
程式人雜誌 -- 2013年5月號鍾誠 陳鍾誠
 
数据处理算法设计要点
数据处理算法设计要点数据处理算法设计要点
数据处理算法设计要点thinkinlamp
 
R統計軟體簡介
R統計軟體簡介R統計軟體簡介
R統計軟體簡介Person Lin
 
Introduction to corona sdk
Introduction to corona sdkIntroduction to corona sdk
Introduction to corona sdk馬 萬圳
 
Metro Style Apps from C++ Developers' View
Metro Style Apps from C++ Developers' ViewMetro Style Apps from C++ Developers' View
Metro Style Apps from C++ Developers' ViewEric ShangKuan
 

Similar to Homework7補充教學 (20)

Python匯出入csv以及繪製圖表初稿
Python匯出入csv以及繪製圖表初稿Python匯出入csv以及繪製圖表初稿
Python匯出入csv以及繪製圖表初稿
 
Python 温故
Python 温故Python 温故
Python 温故
 
Python 于 webgame 的应用
Python 于 webgame 的应用Python 于 webgame 的应用
Python 于 webgame 的应用
 
基于嵌入式系统的Avs P10编码系统设计
基于嵌入式系统的Avs P10编码系统设计基于嵌入式系统的Avs P10编码系统设计
基于嵌入式系统的Avs P10编码系统设计
 
教青少年寫程式
教青少年寫程式教青少年寫程式
教青少年寫程式
 
數位出版2.0 it
數位出版2.0 it數位出版2.0 it
數位出版2.0 it
 
图形学讲义
图形学讲义图形学讲义
图形学讲义
 
給軟體工程師的不廢話 R 語言精要班
給軟體工程師的不廢話 R 語言精要班給軟體工程師的不廢話 R 語言精要班
給軟體工程師的不廢話 R 語言精要班
 
MapReduce 簡單介紹與練習
MapReduce 簡單介紹與練習MapReduce 簡單介紹與練習
MapReduce 簡單介紹與練習
 
漫談 Source Control Management
漫談 Source Control Management漫談 Source Control Management
漫談 Source Control Management
 
Learning python in the motion picture industry by will zhou
Learning python in the motion picture industry   by will zhouLearning python in the motion picture industry   by will zhou
Learning python in the motion picture industry by will zhou
 
R統計軟體 -安裝與使用
R統計軟體 -安裝與使用R統計軟體 -安裝與使用
R統計軟體 -安裝與使用
 
程式人雜誌 -- 2013年5月號
程式人雜誌 -- 2013年5月號程式人雜誌 -- 2013年5月號
程式人雜誌 -- 2013年5月號
 
数据处理算法设计要点
数据处理算法设计要点数据处理算法设计要点
数据处理算法设计要点
 
getPDF.aspx
getPDF.aspxgetPDF.aspx
getPDF.aspx
 
getPDF.aspx
getPDF.aspxgetPDF.aspx
getPDF.aspx
 
R統計軟體簡介
R統計軟體簡介R統計軟體簡介
R統計軟體簡介
 
Introduction to corona sdk
Introduction to corona sdkIntroduction to corona sdk
Introduction to corona sdk
 
Python story
Python storyPython story
Python story
 
Metro Style Apps from C++ Developers' View
Metro Style Apps from C++ Developers' ViewMetro Style Apps from C++ Developers' View
Metro Style Apps from C++ Developers' View
 

More from Jessica Hsieh

More from Jessica Hsieh (10)

Hw12#5
Hw12#5Hw12#5
Hw12#5
 
10401_206296_Hw12
10401_206296_Hw1210401_206296_Hw12
10401_206296_Hw12
 
10401_206296_Hw11
10401_206296_Hw1110401_206296_Hw11
10401_206296_Hw11
 
10401_206296_Hw9
10401_206296_Hw910401_206296_Hw9
10401_206296_Hw9
 
10401_206296_Hw8
10401_206296_Hw810401_206296_Hw8
10401_206296_Hw8
 
10401_206296_Hw7
10401_206296_Hw710401_206296_Hw7
10401_206296_Hw7
 
10401_206296_Hw6
10401_206296_Hw610401_206296_Hw6
10401_206296_Hw6
 
10401_206296_Hw4&5
10401_206296_Hw4&510401_206296_Hw4&5
10401_206296_Hw4&5
 
10401_206296_Hw2
10401_206296_Hw210401_206296_Hw2
10401_206296_Hw2
 
10401_206296_Hw1
10401_206296_Hw110401_206296_Hw1
10401_206296_Hw1
 

Homework7補充教學

  • 1. Homework#7 Problem 2 補充教學 Computer Programming, Fall 2014, Taipei Tech EECS 1
  • 2. 題目要求 180° Computer Programming, Fall 2014, Taipei Tech EECS 2
  • 3. 小提醒 • PPM檔windows沒有內建打得開的軟體喔~ • 老師的PDF有可以打開PPM檔的程式連結 • IrfanView免安裝任意門: • http://www.azofreeware.com/2012/03/irfanview-432.html Computer Programming, Fall 2014, Taipei Tech EECS 3
  • 4. 什麼是PPM? • 不是化學濃度單位XD • PPM是一種圖片格式,常見類型為24位RGB二進制保存 Computer Programming, Fall 2014, Taipei Tech EECS 4
  • 5. PPM(Portable PixMap) • PPM,其實就是把每一個點的RGB分別保存起來。所以,PPM格式的 文件是沒有壓縮的,相對比較大,但是由於圖片格式簡單,一般作為圖 片處理的中間文件(不會丟失文件信息),或者作為簡單的圖片格式保 存。 Computer Programming, Fall 2014, Taipei Tech EECS 5
  • 6. PPM格式分析 • 第一部分是文件magic number • 第二部分是圖像寬度和高度(空格隔開) • 第三部分是描述像素的最大顏色組成(0-255) Computer Programming, Fall 2014, Taipei Tech EECS 6
  • 7. 255 0 0 0 255 0 0 0 255 255 255 0 255 255 255 0 0 0 0 1 2 0 1 Array長這樣: (unsigned char array[2*3*3] ) 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 255 0 0 0 255 0 0 0 255 255 255 0 255 255 255 0 0 0 所以當我要抓第2行第1個(1, 0)像素=> array[1*3*3] 抓座標在(x, y)的像素=> array[(x*圖片寬度+y)*3] Computer Programming, Fall 2014, Taipei Tech EECS 7
  • 8. string.h memmove() • 以下程式從字元陣列t 拷貝6 個字元替換字元 陣列s 前端的6 個字元 • #include <stdio.h> • #include <string.h> • int main(void) • { • char s[20] = "out of work"; • char t[20] = "future"; • memmove(s, t, 6); • printf("%sn", s); • return 0; • } Computer Programming, Fall 2014, Taipei Tech EECS 8
  • 9. temp = (unsigned char *)malloc(w*h*3); for(i = 0;i < h/2;i++) { memmove(temp, &image[i*w*3], sizeof(unsigned char)*w*3); memmove(&image[i*w*3], &image[(h-i-1)*w*3], sizeof(unsigned char)*w*3); memmove(&image[(h-i-1)*w*3], temp, sizeof(unsigned char)*w*3); } 水平 鏡像 Computer Programming, Fall 2014, Taipei Tech EECS 9
  • 10. • 可是題目要的是旋轉180°欸…… • 水平鏡像翻轉之後再做垂直鏡像翻轉就成功啦~~~ Computer Programming, Fall 2014, Taipei Tech EECS 10