No Description

arrays-SimpleImageEditor.html 62KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502
  1. <!DOCTYPE html><html><head><meta charset="utf-8"><style>body {
  2. width: 45em;
  3. border: 1px solid #ddd;
  4. outline: 1300px solid #fff;
  5. margin: 16px auto;
  6. }
  7. body .markdown-body
  8. {
  9. padding: 30px;
  10. }
  11. @font-face {
  12. font-family: octicons-anchor;
  13. src: url(data:font/woff;charset=utf-8;base64,d09GRgABAAAAAAYcAA0AAAAACjQAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABGRlRNAAABMAAAABwAAAAca8vGTk9TLzIAAAFMAAAARAAAAFZG1VHVY21hcAAAAZAAAAA+AAABQgAP9AdjdnQgAAAB0AAAAAQAAAAEACICiGdhc3AAAAHUAAAACAAAAAj//wADZ2x5ZgAAAdwAAADRAAABEKyikaNoZWFkAAACsAAAAC0AAAA2AtXoA2hoZWEAAALgAAAAHAAAACQHngNFaG10eAAAAvwAAAAQAAAAEAwAACJsb2NhAAADDAAAAAoAAAAKALIAVG1heHAAAAMYAAAAHwAAACABEAB2bmFtZQAAAzgAAALBAAAFu3I9x/Nwb3N0AAAF/AAAAB0AAAAvaoFvbwAAAAEAAAAAzBdyYwAAAADP2IQvAAAAAM/bz7t4nGNgZGFgnMDAysDB1Ml0hoGBoR9CM75mMGLkYGBgYmBlZsAKAtJcUxgcPsR8iGF2+O/AEMPsznAYKMwIkgMA5REMOXicY2BgYGaAYBkGRgYQsAHyGMF8FgYFIM0ChED+h5j//yEk/3KoSgZGNgYYk4GRCUgwMaACRoZhDwCs7QgGAAAAIgKIAAAAAf//AAJ4nHWMMQrCQBBF/0zWrCCIKUQsTDCL2EXMohYGSSmorScInsRGL2DOYJe0Ntp7BK+gJ1BxF1stZvjz/v8DRghQzEc4kIgKwiAppcA9LtzKLSkdNhKFY3HF4lK69ExKslx7Xa+vPRVS43G98vG1DnkDMIBUgFN0MDXflU8tbaZOUkXUH0+U27RoRpOIyCKjbMCVejwypzJJG4jIwb43rfl6wbwanocrJm9XFYfskuVC5K/TPyczNU7b84CXcbxks1Un6H6tLH9vf2LRnn8Ax7A5WQAAAHicY2BkYGAA4teL1+yI57f5ysDNwgAC529f0kOmWRiYVgEpDgYmEA8AUzEKsQAAAHicY2BkYGB2+O/AEMPCAAJAkpEBFbAAADgKAe0EAAAiAAAAAAQAAAAEAAAAAAAAKgAqACoAiAAAeJxjYGRgYGBhsGFgYgABEMkFhAwM/xn0QAIAD6YBhwB4nI1Ty07cMBS9QwKlQapQW3VXySvEqDCZGbGaHULiIQ1FKgjWMxknMfLEke2A+IJu+wntrt/QbVf9gG75jK577Lg8K1qQPCfnnnt8fX1NRC/pmjrk/zprC+8D7tBy9DHgBXoWfQ44Av8t4Bj4Z8CLtBL9CniJluPXASf0Lm4CXqFX8Q84dOLnMB17N4c7tBo1AS/Qi+hTwBH4rwHHwN8DXqQ30XXAS7QaLwSc0Gn8NuAVWou/gFmnjLrEaEh9GmDdDGgL3B4JsrRPDU2hTOiMSuJUIdKQQayiAth69r6akSSFqIJuA19TrzCIaY8sIoxyrNIrL//pw7A2iMygkX5vDj+G+kuoLdX4GlGK/8Lnlz6/h9MpmoO9rafrz7ILXEHHaAx95s9lsI7AHNMBWEZHULnfAXwG9/ZqdzLI08iuwRloXE8kfhXYAvE23+23DU3t626rbs8/8adv+9DWknsHp3E17oCf+Z48rvEQNZ78paYM38qfk3v/u3l3u3GXN2Dmvmvpf1Srwk3pB/VSsp512bA/GG5i2WJ7wu430yQ5K3nFGiOqgtmSB5pJVSizwaacmUZzZhXLlZTq8qGGFY2YcSkqbth6aW1tRmlaCFs2016m5qn36SbJrqosG4uMV4aP2PHBmB3tjtmgN2izkGQyLWprekbIntJFing32a5rKWCN/SdSoga45EJykyQ7asZvHQ8PTm6cslIpwyeyjbVltNikc2HTR7YKh9LBl9DADC0U/jLcBZDKrMhUBfQBvXRzLtFtjU9eNHKin0x5InTqb8lNpfKv1s1xHzTXRqgKzek/mb7nB8RZTCDhGEX3kK/8Q75AmUM/eLkfA+0Hi908Kx4eNsMgudg5GLdRD7a84npi+YxNr5i5KIbW5izXas7cHXIMAau1OueZhfj+cOcP3P8MNIWLyYOBuxL6DRylJ4cAAAB4nGNgYoAALjDJyIAOWMCiTIxMLDmZedkABtIBygAAAA==) format('woff');
  14. }
  15. .markdown-body {
  16. -ms-text-size-adjust: 100%;
  17. -webkit-text-size-adjust: 100%;
  18. color: #333;
  19. overflow: hidden;
  20. font-family: "Helvetica Neue", Helvetica, "Segoe UI", Arial, freesans, sans-serif;
  21. font-size: 16px;
  22. line-height: 1.6;
  23. word-wrap: break-word;
  24. }
  25. .markdown-body a {
  26. background: transparent;
  27. }
  28. .markdown-body a:active,
  29. .markdown-body a:hover {
  30. outline: 0;
  31. }
  32. .markdown-body strong {
  33. font-weight: bold;
  34. }
  35. .markdown-body h1 {
  36. font-size: 2em;
  37. margin: 0.67em 0;
  38. }
  39. .markdown-body img {
  40. border: 0;
  41. }
  42. .markdown-body hr {
  43. -moz-box-sizing: content-box;
  44. box-sizing: content-box;
  45. height: 0;
  46. }
  47. .markdown-body pre {
  48. overflow: auto;
  49. }
  50. .markdown-body code,
  51. .markdown-body kbd,
  52. .markdown-body pre {
  53. font-family: monospace, monospace;
  54. font-size: 1em;
  55. }
  56. .markdown-body input {
  57. color: inherit;
  58. font: inherit;
  59. margin: 0;
  60. }
  61. .markdown-body html input[disabled] {
  62. cursor: default;
  63. }
  64. .markdown-body input {
  65. line-height: normal;
  66. }
  67. .markdown-body input[type="checkbox"] {
  68. -moz-box-sizing: border-box;
  69. box-sizing: border-box;
  70. padding: 0;
  71. }
  72. .markdown-body table {
  73. border-collapse: collapse;
  74. border-spacing: 0;
  75. }
  76. .markdown-body td,
  77. .markdown-body th {
  78. padding: 0;
  79. }
  80. .markdown-body * {
  81. -moz-box-sizing: border-box;
  82. box-sizing: border-box;
  83. }
  84. .markdown-body input {
  85. font: 13px/1.4 Helvetica, arial, freesans, clean, sans-serif, "Segoe UI Emoji", "Segoe UI Symbol";
  86. }
  87. .markdown-body a {
  88. color: #4183c4;
  89. text-decoration: none;
  90. }
  91. .markdown-body a:hover,
  92. .markdown-body a:focus,
  93. .markdown-body a:active {
  94. text-decoration: underline;
  95. }
  96. .markdown-body hr {
  97. height: 0;
  98. margin: 15px 0;
  99. overflow: hidden;
  100. background: transparent;
  101. border: 0;
  102. border-bottom: 1px solid #ddd;
  103. }
  104. .markdown-body hr:before {
  105. display: table;
  106. content: "";
  107. }
  108. .markdown-body hr:after {
  109. display: table;
  110. clear: both;
  111. content: "";
  112. }
  113. .markdown-body h1,
  114. .markdown-body h2,
  115. .markdown-body h3,
  116. .markdown-body h4,
  117. .markdown-body h5,
  118. .markdown-body h6 {
  119. margin-top: 15px;
  120. margin-bottom: 15px;
  121. line-height: 1.1;
  122. }
  123. .markdown-body h1 {
  124. font-size: 30px;
  125. }
  126. .markdown-body h2 {
  127. font-size: 21px;
  128. }
  129. .markdown-body h3 {
  130. font-size: 16px;
  131. }
  132. .markdown-body h4 {
  133. font-size: 14px;
  134. }
  135. .markdown-body h5 {
  136. font-size: 12px;
  137. }
  138. .markdown-body h6 {
  139. font-size: 11px;
  140. }
  141. .markdown-body blockquote {
  142. margin: 0;
  143. }
  144. .markdown-body ul,
  145. .markdown-body ol {
  146. padding: 0;
  147. margin-top: 0;
  148. margin-bottom: 0;
  149. }
  150. .markdown-body ol ol,
  151. .markdown-body ul ol {
  152. list-style-type: lower-roman;
  153. }
  154. .markdown-body ul ul ol,
  155. .markdown-body ul ol ol,
  156. .markdown-body ol ul ol,
  157. .markdown-body ol ol ol {
  158. list-style-type: lower-alpha;
  159. }
  160. .markdown-body dd {
  161. margin-left: 0;
  162. }
  163. .markdown-body code {
  164. font: 12px Consolas, "Liberation Mono", Menlo, Courier, monospace;
  165. }
  166. .markdown-body pre {
  167. margin-top: 0;
  168. margin-bottom: 0;
  169. font: 12px Consolas, "Liberation Mono", Menlo, Courier, monospace;
  170. }
  171. .markdown-body .octicon {
  172. font: normal normal 16px octicons-anchor;
  173. line-height: 1;
  174. display: inline-block;
  175. text-decoration: none;
  176. -webkit-font-smoothing: antialiased;
  177. -moz-osx-font-smoothing: grayscale;
  178. -webkit-user-select: none;
  179. -moz-user-select: none;
  180. -ms-user-select: none;
  181. user-select: none;
  182. }
  183. .markdown-body .octicon-link:before {
  184. content: '\f05c';
  185. }
  186. .markdown-body>*:first-child {
  187. margin-top: 0 !important;
  188. }
  189. .markdown-body>*:last-child {
  190. margin-bottom: 0 !important;
  191. }
  192. .markdown-body .anchor {
  193. position: absolute;
  194. top: 0;
  195. bottom: 0;
  196. left: 0;
  197. display: block;
  198. padding-right: 6px;
  199. padding-left: 30px;
  200. margin-left: -30px;
  201. }
  202. .markdown-body .anchor:focus {
  203. outline: none;
  204. }
  205. .markdown-body h1,
  206. .markdown-body h2,
  207. .markdown-body h3,
  208. .markdown-body h4,
  209. .markdown-body h5,
  210. .markdown-body h6 {
  211. position: relative;
  212. margin-top: 1em;
  213. margin-bottom: 16px;
  214. font-weight: bold;
  215. line-height: 1.4;
  216. }
  217. .markdown-body h1 .octicon-link,
  218. .markdown-body h2 .octicon-link,
  219. .markdown-body h3 .octicon-link,
  220. .markdown-body h4 .octicon-link,
  221. .markdown-body h5 .octicon-link,
  222. .markdown-body h6 .octicon-link {
  223. display: none;
  224. color: #000;
  225. vertical-align: middle;
  226. }
  227. .markdown-body h1:hover .anchor,
  228. .markdown-body h2:hover .anchor,
  229. .markdown-body h3:hover .anchor,
  230. .markdown-body h4:hover .anchor,
  231. .markdown-body h5:hover .anchor,
  232. .markdown-body h6:hover .anchor {
  233. padding-left: 8px;
  234. margin-left: -30px;
  235. line-height: 1;
  236. text-decoration: none;
  237. }
  238. .markdown-body h1:hover .anchor .octicon-link,
  239. .markdown-body h2:hover .anchor .octicon-link,
  240. .markdown-body h3:hover .anchor .octicon-link,
  241. .markdown-body h4:hover .anchor .octicon-link,
  242. .markdown-body h5:hover .anchor .octicon-link,
  243. .markdown-body h6:hover .anchor .octicon-link {
  244. display: inline-block;
  245. }
  246. .markdown-body h1 {
  247. padding-bottom: 0.3em;
  248. font-size: 2.25em;
  249. line-height: 1.2;
  250. border-bottom: 1px solid #eee;
  251. }
  252. .markdown-body h2 {
  253. padding-bottom: 0.3em;
  254. font-size: 1.75em;
  255. line-height: 1.225;
  256. border-bottom: 1px solid #eee;
  257. }
  258. .markdown-body h3 {
  259. font-size: 1.5em;
  260. line-height: 1.43;
  261. }
  262. .markdown-body h4 {
  263. font-size: 1.25em;
  264. }
  265. .markdown-body h5 {
  266. font-size: 1em;
  267. }
  268. .markdown-body h6 {
  269. font-size: 1em;
  270. color: #777;
  271. }
  272. .markdown-body p,
  273. .markdown-body blockquote,
  274. .markdown-body ul,
  275. .markdown-body ol,
  276. .markdown-body dl,
  277. .markdown-body table,
  278. .markdown-body pre {
  279. margin-top: 0;
  280. margin-bottom: 16px;
  281. }
  282. .markdown-body hr {
  283. height: 4px;
  284. padding: 0;
  285. margin: 16px 0;
  286. background-color: #e7e7e7;
  287. border: 0 none;
  288. }
  289. .markdown-body ul,
  290. .markdown-body ol {
  291. padding-left: 2em;
  292. }
  293. .markdown-body ul ul,
  294. .markdown-body ul ol,
  295. .markdown-body ol ol,
  296. .markdown-body ol ul {
  297. margin-top: 0;
  298. margin-bottom: 0;
  299. }
  300. .markdown-body li>p {
  301. margin-top: 16px;
  302. }
  303. .markdown-body dl {
  304. padding: 0;
  305. }
  306. .markdown-body dl dt {
  307. padding: 0;
  308. margin-top: 16px;
  309. font-size: 1em;
  310. font-style: italic;
  311. font-weight: bold;
  312. }
  313. .markdown-body dl dd {
  314. padding: 0 16px;
  315. margin-bottom: 16px;
  316. }
  317. .markdown-body blockquote {
  318. padding: 0 15px;
  319. color: #777;
  320. border-left: 4px solid #ddd;
  321. }
  322. .markdown-body blockquote>:first-child {
  323. margin-top: 0;
  324. }
  325. .markdown-body blockquote>:last-child {
  326. margin-bottom: 0;
  327. }
  328. .markdown-body table {
  329. display: block;
  330. width: 100%;
  331. overflow: auto;
  332. word-break: normal;
  333. word-break: keep-all;
  334. }
  335. .markdown-body table th {
  336. font-weight: bold;
  337. }
  338. .markdown-body table th,
  339. .markdown-body table td {
  340. padding: 6px 13px;
  341. border: 1px solid #ddd;
  342. }
  343. .markdown-body table tr {
  344. background-color: #fff;
  345. border-top: 1px solid #ccc;
  346. }
  347. .markdown-body table tr:nth-child(2n) {
  348. background-color: #f8f8f8;
  349. }
  350. .markdown-body img {
  351. max-width: 100%;
  352. -moz-box-sizing: border-box;
  353. box-sizing: border-box;
  354. }
  355. .markdown-body code {
  356. padding: 0;
  357. padding-top: 0.2em;
  358. padding-bottom: 0.2em;
  359. margin: 0;
  360. font-size: 85%;
  361. background-color: rgba(0,0,0,0.04);
  362. border-radius: 3px;
  363. }
  364. .markdown-body code:before,
  365. .markdown-body code:after {
  366. letter-spacing: -0.2em;
  367. content: "\00a0";
  368. }
  369. .markdown-body pre>code {
  370. padding: 0;
  371. margin: 0;
  372. font-size: 100%;
  373. word-break: normal;
  374. white-space: pre;
  375. background: transparent;
  376. border: 0;
  377. }
  378. .markdown-body .highlight {
  379. margin-bottom: 16px;
  380. }
  381. .markdown-body .highlight pre,
  382. .markdown-body pre {
  383. padding: 16px;
  384. overflow: auto;
  385. font-size: 85%;
  386. line-height: 1.45;
  387. background-color: #f7f7f7;
  388. border-radius: 3px;
  389. }
  390. .markdown-body .highlight pre {
  391. margin-bottom: 0;
  392. word-break: normal;
  393. }
  394. .markdown-body pre {
  395. word-wrap: normal;
  396. }
  397. .markdown-body pre code {
  398. display: inline;
  399. max-width: initial;
  400. padding: 0;
  401. margin: 0;
  402. overflow: initial;
  403. line-height: inherit;
  404. word-wrap: normal;
  405. background-color: transparent;
  406. border: 0;
  407. }
  408. .markdown-body pre code:before,
  409. .markdown-body pre code:after {
  410. content: normal;
  411. }
  412. .markdown-body .highlight {
  413. background: #fff;
  414. }
  415. .markdown-body .highlight .h {
  416. color: #333;
  417. font-style: normal;
  418. font-weight: normal;
  419. }
  420. .markdown-body .highlight .mf,
  421. .markdown-body .highlight .mh,
  422. .markdown-body .highlight .mi,
  423. .markdown-body .highlight .mo,
  424. .markdown-body .highlight .il,
  425. .markdown-body .highlight .m {
  426. color: #945277;
  427. }
  428. .markdown-body .highlight .s,
  429. .markdown-body .highlight .sb,
  430. .markdown-body .highlight .sc,
  431. .markdown-body .highlight .sd,
  432. .markdown-body .highlight .s2,
  433. .markdown-body .highlight .se,
  434. .markdown-body .highlight .sh,
  435. .markdown-body .highlight .si,
  436. .markdown-body .highlight .sx,
  437. .markdown-body .highlight .s1 {
  438. color: #df5000;
  439. }
  440. .markdown-body .highlight .kc,
  441. .markdown-body .highlight .kd,
  442. .markdown-body .highlight .kn,
  443. .markdown-body .highlight .kp,
  444. .markdown-body .highlight .kr,
  445. .markdown-body .highlight .kt,
  446. .markdown-body .highlight .k,
  447. .markdown-body .highlight .o {
  448. font-weight: bold;
  449. }
  450. .markdown-body .highlight .kt {
  451. color: #458;
  452. }
  453. .markdown-body .highlight .c,
  454. .markdown-body .highlight .cm,
  455. .markdown-body .highlight .c1 {
  456. color: #998;
  457. font-style: italic;
  458. }
  459. .markdown-body .highlight .cp,
  460. .markdown-body .highlight .cs,
  461. .markdown-body .highlight .cp .h {
  462. color: #999;
  463. font-weight: bold;
  464. }
  465. .markdown-body .highlight .cs {
  466. font-style: italic;
  467. }
  468. .markdown-body .highlight .n {
  469. color: #333;
  470. }
  471. .markdown-body .highlight .na,
  472. .markdown-body .highlight .nv,
  473. .markdown-body .highlight .vc,
  474. .markdown-body .highlight .vg,
  475. .markdown-body .highlight .vi {
  476. color: #008080;
  477. }
  478. .markdown-body .highlight .nb {
  479. color: #0086B3;
  480. }
  481. .markdown-body .highlight .nc {
  482. color: #458;
  483. font-weight: bold;
  484. }
  485. .markdown-body .highlight .no {
  486. color: #094e99;
  487. }
  488. .markdown-body .highlight .ni {
  489. color: #800080;
  490. }
  491. .markdown-body .highlight .ne {
  492. color: #990000;
  493. font-weight: bold;
  494. }
  495. .markdown-body .highlight .nf {
  496. color: #945277;
  497. font-weight: bold;
  498. }
  499. .markdown-body .highlight .nn {
  500. color: #555;
  501. }
  502. .markdown-body .highlight .nt {
  503. color: #000080;
  504. }
  505. .markdown-body .highlight .err {
  506. color: #a61717;
  507. background-color: #e3d2d2;
  508. }
  509. .markdown-body .highlight .gd {
  510. color: #000;
  511. background-color: #fdd;
  512. }
  513. .markdown-body .highlight .gd .x {
  514. color: #000;
  515. background-color: #faa;
  516. }
  517. .markdown-body .highlight .ge {
  518. font-style: italic;
  519. }
  520. .markdown-body .highlight .gr {
  521. color: #aa0000;
  522. }
  523. .markdown-body .highlight .gh {
  524. color: #999;
  525. }
  526. .markdown-body .highlight .gi {
  527. color: #000;
  528. background-color: #dfd;
  529. }
  530. .markdown-body .highlight .gi .x {
  531. color: #000;
  532. background-color: #afa;
  533. }
  534. .markdown-body .highlight .go {
  535. color: #888;
  536. }
  537. .markdown-body .highlight .gp {
  538. color: #555;
  539. }
  540. .markdown-body .highlight .gs {
  541. font-weight: bold;
  542. }
  543. .markdown-body .highlight .gu {
  544. color: #800080;
  545. font-weight: bold;
  546. }
  547. .markdown-body .highlight .gt {
  548. color: #aa0000;
  549. }
  550. .markdown-body .highlight .ow {
  551. font-weight: bold;
  552. }
  553. .markdown-body .highlight .w {
  554. color: #bbb;
  555. }
  556. .markdown-body .highlight .sr {
  557. color: #017936;
  558. }
  559. .markdown-body .highlight .ss {
  560. color: #8b467f;
  561. }
  562. .markdown-body .highlight .bp {
  563. color: #999;
  564. }
  565. .markdown-body .highlight .gc {
  566. color: #999;
  567. background-color: #EAF2F5;
  568. }
  569. .markdown-body kbd {
  570. background-color: #e7e7e7;
  571. background-image: -webkit-linear-gradient(#fefefe, #e7e7e7);
  572. background-image: linear-gradient(#fefefe, #e7e7e7);
  573. background-repeat: repeat-x;
  574. display: inline-block;
  575. padding: 3px 5px;
  576. font: 11px Consolas, "Liberation Mono", Menlo, Courier, monospace;
  577. line-height: 10px;
  578. color: #000;
  579. border: 1px solid #cfcfcf;
  580. border-radius: 2px;
  581. }
  582. .markdown-body .highlight .pl-coc,
  583. .markdown-body .highlight .pl-entm,
  584. .markdown-body .highlight .pl-eoa,
  585. .markdown-body .highlight .pl-mai .pl-sf,
  586. .markdown-body .highlight .pl-pdv,
  587. .markdown-body .highlight .pl-sc,
  588. .markdown-body .highlight .pl-sr,
  589. .markdown-body .highlight .pl-v,
  590. .markdown-body .highlight .pl-vpf {
  591. color: #0086b3;
  592. }
  593. .markdown-body .highlight .pl-eoac,
  594. .markdown-body .highlight .pl-mdht,
  595. .markdown-body .highlight .pl-mi1,
  596. .markdown-body .highlight .pl-mri,
  597. .markdown-body .highlight .pl-va,
  598. .markdown-body .highlight .pl-vpu {
  599. color: #008080;
  600. }
  601. .markdown-body .highlight .pl-c,
  602. .markdown-body .highlight .pl-pdc {
  603. color: #b4b7b4;
  604. font-style: italic;
  605. }
  606. .markdown-body .highlight .pl-k,
  607. .markdown-body .highlight .pl-ko,
  608. .markdown-body .highlight .pl-kolp,
  609. .markdown-body .highlight .pl-mc,
  610. .markdown-body .highlight .pl-mr,
  611. .markdown-body .highlight .pl-ms,
  612. .markdown-body .highlight .pl-s,
  613. .markdown-body .highlight .pl-sok,
  614. .markdown-body .highlight .pl-st {
  615. color: #6e5494;
  616. }
  617. .markdown-body .highlight .pl-ef,
  618. .markdown-body .highlight .pl-enf,
  619. .markdown-body .highlight .pl-enm,
  620. .markdown-body .highlight .pl-entc,
  621. .markdown-body .highlight .pl-eoi,
  622. .markdown-body .highlight .pl-sf,
  623. .markdown-body .highlight .pl-smc {
  624. color: #d12089;
  625. }
  626. .markdown-body .highlight .pl-ens,
  627. .markdown-body .highlight .pl-eoai,
  628. .markdown-body .highlight .pl-kos,
  629. .markdown-body .highlight .pl-mh .pl-pdh,
  630. .markdown-body .highlight .pl-mp,
  631. .markdown-body .highlight .pl-pde,
  632. .markdown-body .highlight .pl-stp {
  633. color: #458;
  634. }
  635. .markdown-body .highlight .pl-enti {
  636. color: #d12089;
  637. font-weight: bold;
  638. }
  639. .markdown-body .highlight .pl-cce,
  640. .markdown-body .highlight .pl-enc,
  641. .markdown-body .highlight .pl-kou,
  642. .markdown-body .highlight .pl-mq {
  643. color: #f93;
  644. }
  645. .markdown-body .highlight .pl-mp1 .pl-sf {
  646. color: #458;
  647. font-weight: bold;
  648. }
  649. .markdown-body .highlight .pl-cos,
  650. .markdown-body .highlight .pl-ent,
  651. .markdown-body .highlight .pl-md,
  652. .markdown-body .highlight .pl-mdhf,
  653. .markdown-body .highlight .pl-ml,
  654. .markdown-body .highlight .pl-pdc1,
  655. .markdown-body .highlight .pl-pds,
  656. .markdown-body .highlight .pl-s1,
  657. .markdown-body .highlight .pl-scp,
  658. .markdown-body .highlight .pl-sol {
  659. color: #df5000;
  660. }
  661. .markdown-body .highlight .pl-c1,
  662. .markdown-body .highlight .pl-cn,
  663. .markdown-body .highlight .pl-pse,
  664. .markdown-body .highlight .pl-pse .pl-s2,
  665. .markdown-body .highlight .pl-vi {
  666. color: #a31515;
  667. }
  668. .markdown-body .highlight .pl-mb,
  669. .markdown-body .highlight .pl-pdb {
  670. color: #df5000;
  671. font-weight: bold;
  672. }
  673. .markdown-body .highlight .pl-mi,
  674. .markdown-body .highlight .pl-pdi {
  675. color: #6e5494;
  676. font-style: italic;
  677. }
  678. .markdown-body .highlight .pl-ms1 {
  679. background-color: #f5f5f5;
  680. }
  681. .markdown-body .highlight .pl-mdh,
  682. .markdown-body .highlight .pl-mdi {
  683. font-weight: bold;
  684. }
  685. .markdown-body .highlight .pl-mdr {
  686. color: #0086b3;
  687. font-weight: bold;
  688. }
  689. .markdown-body .highlight .pl-s2 {
  690. color: #333;
  691. }
  692. .markdown-body .highlight .pl-ii {
  693. background-color: #df5000;
  694. color: #fff;
  695. }
  696. .markdown-body .highlight .pl-ib {
  697. background-color: #f93;
  698. }
  699. .markdown-body .highlight .pl-id {
  700. background-color: #a31515;
  701. color: #fff;
  702. }
  703. .markdown-body .highlight .pl-iu {
  704. background-color: #b4b7b4;
  705. }
  706. .markdown-body .highlight .pl-mo {
  707. color: #969896;
  708. }
  709. .markdown-body .task-list-item {
  710. list-style-type: none;
  711. }
  712. .markdown-body .task-list-item+.task-list-item {
  713. margin-top: 3px;
  714. }
  715. .markdown-body .task-list-item input {
  716. float: left;
  717. margin: 0.3em 0 0.25em -1.6em;
  718. vertical-align: middle;
  719. }</style><script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
  720. <script>
  721. MathJax.Hub.Config({
  722. config: ["MMLorHTML.js"],
  723. extensions: ["tex2jax.js"],
  724. jax: ["input/TeX"],
  725. tex2jax: {
  726. inlineMath: [ ['$','$'], ["\\(","\\)"] ],
  727. displayMath: [ ['$$','$$'], ["\\[","\\]"] ],
  728. processEscapes: false
  729. },
  730. TeX: {
  731. extensions: ["AMSmath.js", "AMSsymbols.js"],
  732. TagSide: "right",
  733. TagIndent: ".8em",
  734. MultLineWidth: "85%",
  735. equationNumbers: {
  736. autoNumber: "AMS",
  737. },
  738. unicode: {
  739. fonts: "STIXGeneral,'Arial Unicode MS'"
  740. }
  741. },
  742. showProcessingMessages: false
  743. });
  744. </script>
  745. <title>arrays-SimpleImageEditor</title></head><body><article class="markdown-body"><p><a href="#markdown-header-arrays-simple-image-editor">English</a> | <a href="#markdown-header-arreglos-editor-de-imagenes-simple">Español</a></p>
  746. <h1>
  747. <a id="user-content-arreglos---editor-de-imagenes-simple" class="anchor" href="#arreglos---editor-de-imagenes-simple" aria-hidden="true"><span class="octicon octicon-link"></span></a>Arreglos - Editor de Imagenes Simple</h1>
  748. <p><a href="/Users/Ivelisse/Dropbox/eip/EIP-REVISION-VERANO/Arrays/SimpleImageEditor/simpleimageeditor-Edited-NO-Solutions-July-2015/images/main1.png" target="_blank"><img src="/Users/Ivelisse/Dropbox/eip/EIP-REVISION-VERANO/Arrays/SimpleImageEditor/simpleimageeditor-Edited-NO-Solutions-July-2015/images/main1.png" alt="main1.png" style="max-width:100%;"></a>
  749. <a href="/Users/Ivelisse/Dropbox/eip/EIP-REVISION-VERANO/Arrays/SimpleImageEditor/simpleimageeditor-Edited-NO-Solutions-July-2015/images/main2.png" target="_blank"><img src="/Users/Ivelisse/Dropbox/eip/EIP-REVISION-VERANO/Arrays/SimpleImageEditor/simpleimageeditor-Edited-NO-Solutions-July-2015/images/main2.png" alt="main2.png" style="max-width:100%;"></a>
  750. <a href="/Users/Ivelisse/Dropbox/eip/EIP-REVISION-VERANO/Arrays/SimpleImageEditor/simpleimageeditor-Edited-NO-Solutions-July-2015/images/main3.png" target="_blank"><img src="/Users/Ivelisse/Dropbox/eip/EIP-REVISION-VERANO/Arrays/SimpleImageEditor/simpleimageeditor-Edited-NO-Solutions-July-2015/images/main3.png" alt="main3.png" style="max-width:100%;"></a></p>
  751. <p>Los arreglos de datos (<em>arrays</em>) nos facilitan guardar y trabajar con grupos de datos del mismo tipo. Los datos se guardan en espacios de memoria consecutivos a los que se puede acceder utilizando el nombre del arreglo e índices o suscritos que indican la posición en que se encuentra el dato. Las estructuras de repetición nos proveen una manera simple de acceder a los datos de un arreglo. En la experiencia de laboratorio de hoy diseñarás e implementarás algoritmos simples de procesamiento de imágenes para practicar el uso de ciclos anidados en la manipulación de arreglos bi-dimensionales. </p>
  752. <h2>
  753. <a id="user-content-objetivos" class="anchor" href="#objetivos" aria-hidden="true"><span class="octicon octicon-link"></span></a>Objetivos:</h2>
  754. <ol>
  755. <li><p>Practicar el acceder y manipular datos en un arreglo.</p></li>
  756. <li><p>Aplicar ciclos anidados para implementar algoritmos simples de procesamiento de imágenes.</p></li>
  757. <li><p>Utilizar expresiones aritméticas para transformar colores de pixeles.</p></li>
  758. <li><p>Acceder pixeles en una imagen y descomponerlos en sus componentes rojo, azul y verde.</p></li>
  759. </ol>
  760. <h2>
  761. <a id="user-content-pre-lab" class="anchor" href="#pre-lab" aria-hidden="true"><span class="octicon octicon-link"></span></a>Pre-Lab:</h2>
  762. <p>Antes de llegar al laboratorio debes:</p>
  763. <ol>
  764. <li><p>Conseguir y tener disponible uno o más archivos con una imagen a color en alguno de los siguientes formatos: <code>tiff, jpg, png</code>.</p></li>
  765. <li><p>Haber repasado los conceptos básicos relacionados a estructuras de repetición y ciclos anidados.</p></li>
  766. <li><p>Conocer las funciones básicas de <code>QImage</code> para manipular los pixeles de las imágenes. </p></li>
  767. <li><p>Haber estudiado los conceptos e instrucciones para la sesión de laboratorio.</p></li>
  768. <li><p>Haber tomado el quiz Pre-Lab que se encuentra en Moodle.</p></li>
  769. </ol>
  770. <hr>
  771. <hr>
  772. <h2>
  773. <a id="user-content-edición-de-imágenes" class="anchor" href="#edici%C3%B3n-de-im%C3%A1genes" aria-hidden="true"><span class="octicon octicon-link"></span></a>Edición de imágenes</h2>
  774. <p>En esta experiencia de laboratorio, trabajarás con varios conceptos y destrezas básicas de edición de imágenes. Te proveemos un interface gráfico (GUI) simple que le permite al usuario cargar una imagen e invertirla vertical y horizontalmente. Tu tarea es crear e implementar una función para convertir una imagen a color a una imagen con tonos de gris, y otra función que convierta una imagen a color a una imagen en blanco y negro.</p>
  775. <h3>
  776. <a id="user-content-píxeles" class="anchor" href="#p%C3%ADxeles" aria-hidden="true"><span class="octicon octicon-link"></span></a>Píxeles</h3>
  777. <p>Al elemento más pequeño de una imagen se le llama un <em>píxel</em>. Esta unidad consiste de un solo color. Como cada color es una combinación de tonalidades de los colores primarios rojo, verde y azul, se codifica como un entero sin signo cuyos bytes representan los tonos de rojo, verde y azul del pixel (Figura 1). A esta combinación se le llama el <em>RGB</em> del color por las siglas de "Red-Green-Blue". Por ejemplo un píxel de color rojo (puro) tiene una representación RGB <code>0x00ff0000</code>, mientras que un píxel de color blanco tiene una representación RGB de <code>0x00FFFFFF</code> (ya que el color blanco es la combinación de los tonos rojo, verde y azul en toda su intensidad).</p>
  778. <hr>
  779. <p><a href="/Users/Ivelisse/Dropbox/eip/EIP-REVISION-VERANO/Arrays/SimpleImageEditor/simpleimageeditor-Edited-NO-Solutions-July-2015/images/figure1.png" target="_blank"><img src="/Users/Ivelisse/Dropbox/eip/EIP-REVISION-VERANO/Arrays/SimpleImageEditor/simpleimageeditor-Edited-NO-Solutions-July-2015/images/figure1.png" alt="figure1.png" style="max-width:100%;"></a></p>
  780. <p><strong>Figura 1.</strong> Distribución de bits para las tonalidades de rojo, verde y azul dentro de la representación RGB. Cada tonalidad puede tener valores entre 0x00 (los ocho bits en 0) y 0xFF (los 8 bits en 1). </p>
  781. <hr>
  782. <p>En <code>Qt</code> se utiliza el tipo <code>QRgb</code> para representar valores <code>RGB</code>. Utilizando ciertas funciones que describimos abajo podemos obtener los componentes rojo, verde y azul del valor <code>QRgb</code> del píxel y así manipular imágenes.</p>
  783. <h3>
  784. <a id="user-content-biblioteca" class="anchor" href="#biblioteca" aria-hidden="true"><span class="octicon octicon-link"></span></a>Biblioteca</h3>
  785. <p>La experiencia de laboratorio de hoy utilizará la clase <code>QImage</code>. Esta clase permite acceder a los datos de los pixeles de una imagen para poder manipularla. La documentación de la clase <code>QImage</code> se encuentra en <a href="http://doc.qt.io/qt-4.8/qimage.html">http://doc.qt.io/qt-4.8/qimage.html</a>.</p>
  786. <p>El código que te proveemos contiene los siguiente objetos de la clase <code>QImage</code>:</p>
  787. <ul>
  788. <li>
  789. <code>originalImage</code> // contiene la información de la imagen original que vas a editar</li>
  790. <li> <code>editedImage</code> // contendrá la imagen editada</li>
  791. </ul>
  792. <p>Los objetos de clase <code>QImage</code> tienen los siguiente métodos que serán útiles para la experiencia de laboratorio de hoy:</p>
  793. <ul>
  794. <li>
  795. <code>width()</code> // devuelve el valor entero del ancho de la imagen</li>
  796. <li>
  797. <code>height()</code> // devuelve el valor entero de la altura de la imagen</li>
  798. <li>
  799. <code>pixel(i, j)</code> // devuelve el <code>QRgb</code> del píxel en la posición <code>(i,j)</code>
  800. </li>
  801. <li>
  802. <code>setPixel(i,j, pixel)</code> // modifica el valor del píxel en la posición <code>(i, j)</code> al valor píxel <code>QRgb</code>
  803. </li>
  804. </ul>
  805. <p>Las siguientes funciones son útiles para trabajar con datos de tipo <code>QRgb</code>:</p>
  806. <ul>
  807. <li>
  808. <code>qRed(pixel)</code> // devuelve el tono del color rojo del píxel</li>
  809. <li>
  810. <code>qGreen(pixel)</code> // devuelve el tono del color verde del píxel</li>
  811. <li>
  812. <code>qBlue(pixel)</code> // devuelve el tono del color azul del píxel</li>
  813. <li>
  814. <code>qRgb(int red, int green, int blue)</code> // devuelve un píxel <code>QRgb</code> compuesto de los valores de rojo, verde y azul recibidos.</li>
  815. </ul>
  816. <h4>
  817. <a id="user-content-ejemplos" class="anchor" href="#ejemplos" aria-hidden="true"><span class="octicon octicon-link"></span></a>Ejemplos:</h4>
  818. <ol>
  819. <li>
  820. <p><code>QRgb myRgb = qRgb(0xff, 0x00, 0xff);</code>: Asigna a <code>myRgb</code> el valor <code>0xff00ff</code> que representa el color <a href="/Users/Ivelisse/Dropbox/eip/EIP-REVISION-VERANO/Arrays/SimpleImageEditor/simpleimageeditor-Edited-NO-Solutions-July-2015/images/figure2.png" target="_blank"><img src="/Users/Ivelisse/Dropbox/eip/EIP-REVISION-VERANO/Arrays/SimpleImageEditor/simpleimageeditor-Edited-NO-Solutions-July-2015/images/figure2.png" alt="figure2.png" style="max-width:100%;"></a></p>
  821. <p>Nota que el valor <code>0xff00ff</code> representa los valores <code>0xff</code>, <code>0x0</code>, <code>0xff</code>, que corresponden a los componentes rojo, verde y azul de <code>myRgb</code>.</p>
  822. </li>
  823. <li>
  824. <p>Si la siguiente imagen <code>4 x 4</code> de píxeles representa el objeto <code>originalImage</code>,</p>
  825. <p><a href="/Users/Ivelisse/Dropbox/eip/EIP-REVISION-VERANO/Arrays/SimpleImageEditor/simpleimageeditor-Edited-NO-Solutions-July-2015/images/ejemplo.png" target="_blank"><img src="/Users/Ivelisse/Dropbox/eip/EIP-REVISION-VERANO/Arrays/SimpleImageEditor/simpleimageeditor-Edited-NO-Solutions-July-2015/images/ejemplo.png" alt="ejemplo.png" style="max-width:100%;"></a></p>
  826. <p>entonces <code>originalImage.pixel(2,1)</code> devuelve un valor <code>rgb</code> que representa el color azul (<code>0x0000ff</code>).</p>
  827. </li>
  828. <li>
  829. <p>La siguiente instrucción asigna el color rojo al píxel en posición <code>(2,3)</code> en la imagen editada:</p>
  830. <p><code>editedImage.setPixel(2,3,qRgb(0xff,0x00,0x00));</code>.</p>
  831. </li>
  832. <li>
  833. <p>La siguiente instrucción le asigna a <code>greenContent</code> el valor del tono de verde que contiene el pixel <code>(1,1)</code> de <code>originalImage</code>:</p>
  834. <p><code>int greenContent = qGreen(originalImage.pixel(1,1));</code>.</p>
  835. </li>
  836. <li><p>El siguiente programa crea un objeto de clase <code>QImage</code> e imprime los componentes rojo, verde y azul del pixel en el centro de la imagen. La imagen utilizada es la que se especifica dentro del paréntesis durante la creación del objeto, esto es, el archivo <code>chuck.png</code>.</p></li>
  837. </ol>
  838. <hr>
  839. <div class="highlight highlight-cpp"><pre>#<span class="pl-k">include</span> <span class="pl-s"><span class="pl-pds">&lt;</span>QImage<span class="pl-pds">&gt;</span></span>
  840. #<span class="pl-k">include</span> <span class="pl-s"><span class="pl-pds">&lt;</span>iostream<span class="pl-pds">&gt;</span></span>
  841. <span class="pl-k">using</span> <span class="pl-k">namespace</span> <span class="pl-en">std</span><span class="pl-k">;</span>
  842. <span class="pl-k">int</span> <span class="pl-en">main</span>() {
  843. QImage <span class="pl-smi">myImage</span>(“/Users/rarce/Downloads/chuck.<span class="pl-smi">png</span>”);
  844. QRgb centralPixel;
  845. centralPixel = myImage.<span class="pl-c1">pixel</span>(myImage.<span class="pl-c1">width</span>() / <span class="pl-c1">2</span>, myImage.<span class="pl-c1">height</span>() / <span class="pl-c1">2</span>);
  846. cout &lt;&lt; hex;
  847. cout &lt;&lt; “Los componentes rojo, verde y azul del pixel central son: “
  848. &lt;&lt; <span class="pl-c1">qRed</span>(centralPixel) &lt;&lt; “, “
  849. &lt;&lt; <span class="pl-c1">qGreen</span>(centralPixel) &lt;&lt; “, “
  850. &lt;&lt; <span class="pl-c1">qBlue</span>(centralPixel) &lt;&lt; endl;
  851. <span class="pl-k">return</span> <span class="pl-c1">0</span>;
  852. }</pre></div>
  853. <hr>
  854. <hr>
  855. <h2>
  856. <a id="user-content-sesión-de-laboratorio" class="anchor" href="#sesi%C3%B3n-de-laboratorio" aria-hidden="true"><span class="octicon octicon-link"></span></a>Sesión de laboratorio:</h2>
  857. <p>En la experiencia de laboratorio de hoy diseñarás e implementarás algoritmos simples de procesamiento de imágenes para practicar el uso de ciclos anidados en la manipulación de arreglos bi-dimensionales. </p>
  858. <h3>
  859. <a id="user-content-ejercicio-1-entender-el-código-provisto" class="anchor" href="#ejercicio-1-entender-el-c%C3%B3digo-provisto" aria-hidden="true"><span class="octicon octicon-link"></span></a>Ejercicio 1: Entender el código provisto</h3>
  860. <h4>
  861. <a id="user-content-instrucciones" class="anchor" href="#instrucciones" aria-hidden="true"><span class="octicon octicon-link"></span></a>Instrucciones</h4>
  862. <ol>
  863. <li><p>Carga a Qt el proyecto <code>SimpleImageEditor</code> haciendo doble "click" en el archivo <code>SimpleImageEditor.pro</code> en el directorio <code>Documents/eip/Arrays-SimpleImageEditor</code> de tu computadora. También puedes ir a <code>http://bitbucket.org/eip-uprrp/arrays-simpleimageeditor</code> para descargar la carpeta <code>Arrays-SimpleImageEditor</code> a tu computadora.</p></li>
  864. <li>
  865. <p>El código que te proveemos crea la interface de la Figura 2. </p>
  866. <hr>
  867. <p><a href="/Users/Ivelisse/Dropbox/eip/EIP-REVISION-VERANO/Arrays/SimpleImageEditor/simpleimageeditor-Edited-NO-Solutions-July-2015/images/figure3.png" target="_blank"><img src="/Users/Ivelisse/Dropbox/eip/EIP-REVISION-VERANO/Arrays/SimpleImageEditor/simpleimageeditor-Edited-NO-Solutions-July-2015/images/figure3.png" alt="figure3.png" style="max-width:100%;"></a></p>
  868. <p><strong>Figura 2.</strong> Interface del editor de imágenes.</p>
  869. <hr>
  870. </li>
  871. <li>
  872. <p>Estarás trabajando con el archivo <code>filter.cpp</code>. Estudia la función <code>HorizontalFlip</code> del archivo <code>filter.cpp</code> para que entiendas su operación.</p>
  873. <p>En los ejercicios siguientes estarás usando mayormente los objetos <code>originalImage</code> y <code>editedImage</code> de clase <code>QImage</code>. ¿Cuál crees que es el propósito la variable <code>pixel</code>?</p>
  874. </li>
  875. <li>
  876. <p>El código que te proveemos ya tiene programado el funcionamiento de los botones de la interface gráfica. NO tienes que cambiar nada en este código pero te incluimos las siguientes explicaciones para que conozcas un poco del funcionamiento de los botones. En el archivo <code>mainwindow.cpp</code>, las etiquetas <code>lblOriginalImage</code> y <code>lblEditedImage</code> corresponden a las partes de la interface que identifican la imagen original y la imagen procesada. Los botones</p>
  877. <ul>
  878. <li><code>btnLoadImage</code></li>
  879. <li><code>btnSaveImage</code></li>
  880. <li><code>btnInvertThreshold</code></li>
  881. <li><code>btnFlipImageHorizontally</code></li>
  882. <li><code>btnFlipImageVertically</code></li>
  883. <li><code>btnGreyScaleFilter</code></li>
  884. <li>
  885. <code>btnRevertImage</code> </li>
  886. </ul>
  887. <p>están conectados a funciones de modo que cuando se presione el botón de la interface se haga alguna tarea. Por ejemplo, cuando se presiona <code>LoadImage</code>, saldrá una ventana para seleccionar el archivo con la imagen para editar, al seleccionar el archivo, se lee y se asigna la imagen al objeto <code>originalImage</code>. El deslizador <code>thresholdSlider</code> puede asumir valores entre 0 y 255.</p>
  888. </li>
  889. <li><p>Compila y corre el programa. Prueba los botones <code>Load New Image</code> y <code>Flip Image Horizontally</code> con las imágenes que trajiste para que valides las operaciones de los botones.</p></li>
  890. </ol>
  891. <h3>
  892. <a id="user-content-ejercicio-2-convertir-una-imagen-a-colores-a-una-imagen-en-tonos-de-gris" class="anchor" href="#ejercicio-2-convertir-una-imagen-a-colores-a-una-imagen-en-tonos-de-gris" aria-hidden="true"><span class="octicon octicon-link"></span></a>Ejercicio 2: Convertir una imagen a colores a una imagen en tonos de gris</h3>
  893. <p>El "image grayscale" es una operación que se usa para convertir una imagen a color a una imagen que solo tenga tonalidades de gris. Para hacer esta conversión se usa la siguiente fórmula en cada uno de los píxeles:</p>
  894. <p><code>gray = (red * 11 + green * 16 + blue * 5)/32 ;</code></p>
  895. <p>donde <code>red</code>, <code>green</code> y <code>blue</code> son los valores para los tonos de los colores rojo, verde y azul en el píxel de la imagen original a color, y <code>gray</code> será el color asignado a los colores rojo, verde y azul en el píxel de la imagen editada. Esto es,</p>
  896. <p><code>editedImage.setPixel( i, j, qRgb(gray, gray, gray) )</code>.</p>
  897. <h4>
  898. <a id="user-content-instrucciones-1" class="anchor" href="#instrucciones-1" aria-hidden="true"><span class="octicon octicon-link"></span></a>Instrucciones</h4>
  899. <ol>
  900. <li><p>Utilizando pseudocódigo, expresa el algoritmo para convertir una imagen a color a una imagen solo con tonalidades de gris. El apéndice de este documento contiene algunos consejos sobre buenas prácticas al hacer pseudocódigos. </p></li>
  901. <li>
  902. <p>Completa la función <code>GreyScale</code> en el archivo <code>filter.cpp</code> para implementar el algoritmo de tonalidades de gris. La función debe producir un resultado similar al de la Figura 3, en donde la imagen de la izquierda es la imagen original y la de la derecha es la imagen editada.</p>
  903. <hr>
  904. <p><a href="/Users/Ivelisse/Dropbox/eip/EIP-REVISION-VERANO/Arrays/SimpleImageEditor/simpleimageeditor-Edited-NO-Solutions-July-2015/images/chuck-color.png" target="_blank"><img src="/Users/Ivelisse/Dropbox/eip/EIP-REVISION-VERANO/Arrays/SimpleImageEditor/simpleimageeditor-Edited-NO-Solutions-July-2015/images/chuck-color.png" alt="chuck-color.png" style="max-width:100%;"></a>
  905. <a href="/Users/Ivelisse/Dropbox/eip/EIP-REVISION-VERANO/Arrays/SimpleImageEditor/simpleimageeditor-Edited-NO-Solutions-July-2015/images/chuck-gris.png" target="_blank"><img src="/Users/Ivelisse/Dropbox/eip/EIP-REVISION-VERANO/Arrays/SimpleImageEditor/simpleimageeditor-Edited-NO-Solutions-July-2015/images/chuck-gris.png" alt="chuck-gris.png" style="max-width:100%;"></a></p>
  906. <p><strong>Figura 3.</strong> Imagen original e imagen luego de aplicar la función <code>GreyScale</code>.</p>
  907. <hr>
  908. </li>
  909. </ol>
  910. <h3>
  911. <a id="user-content-ejercicio-3-convertir-una-imagen-a-colores-a-una-imagen-en-blanco-y-negro-thresholding" class="anchor" href="#ejercicio-3-convertir-una-imagen-a-colores-a-una-imagen-en-blanco-y-negro-thresholding" aria-hidden="true"><span class="octicon octicon-link"></span></a>Ejercicio 3: Convertir una imagen a colores a una imagen en blanco y negro ("Thresholding")</h3>
  912. <p>"Thresholding" es una operación que se puede utilizar para convertir una imagen a color a una imagen en blanco y negro. Para hacer esta conversión debemos decidir cuáles colores de la imagen original van a convertirse en píxeles blancos y cuáles serán negros. Una manera sencilla de decidir esto es computando el promedio de los componentes rojo, verde y azul de cada píxel. Si el promedio es menor que el valor umbral ("threshold"), entonces cambiamos el píxel a negro; de lo contrario se cambia a blanco.</p>
  913. <h4>
  914. <a id="user-content-instrucciones-2" class="anchor" href="#instrucciones-2" aria-hidden="true"><span class="octicon octicon-link"></span></a>Instrucciones</h4>
  915. <ol>
  916. <li><p>Utilizando pseudocódigo, expresa el algoritmo para "thresholding". Presume que utilizarás el valor del deslizador como umbral.</p></li>
  917. <li><p>En el programa, si la caja <code>chkboxThreshold</code> está marcada, se hace una invocación a la función <code>applyThresholdFilter</code>. La función <code>applyThresholdFilter</code> también es invocada cada vez que se cambia el valor del deslizador.</p></li>
  918. <li><p>Completa la función <code>ThresholdFilter</code> de modo que implemente el algoritmo de "threshold" en la imagen a color utilizando el valor del deslizador como umbral. Si se implementa correctamente, la imagen de la derecha debe ser la imagen original pero en blanco y negro. El valor umbral es un parámetro de la función <code>ThresholdFilter</code>. El código provisto en <code>mainwindow.h</code> tiene definidas las constantes <code>BLACK</code> y <code>WHITE</code> con el valor hexadecimal de los colores negro y blanco respectivamente; puedes aprovechar esto y utilizarlas en tu código.</p></li>
  919. <li><p>El parámetro booleano <code>invertColor</code> tendrá el valor <code>true</code> si la opción de invertir los colores fue seleccionada. Escribe código de modo que los colores blanco y negro se inviertan en la imagen si <code>invertColor</code> asume el valor <code>true</code>.</p></li>
  920. <li>
  921. <p>Prueba tu programa con distintas imágenes y distintos valores de umbral.</p>
  922. <hr>
  923. <p><a href="/Users/Ivelisse/Dropbox/eip/EIP-REVISION-VERANO/Arrays/SimpleImageEditor/simpleimageeditor-Edited-NO-Solutions-July-2015/images/chuck-color.png" target="_blank"><img src="/Users/Ivelisse/Dropbox/eip/EIP-REVISION-VERANO/Arrays/SimpleImageEditor/simpleimageeditor-Edited-NO-Solutions-July-2015/images/chuck-color.png" alt="chuck-color.png" style="max-width:100%;"></a>
  924. <a href="/Users/Ivelisse/Dropbox/eip/EIP-REVISION-VERANO/Arrays/SimpleImageEditor/simpleimageeditor-Edited-NO-Solutions-July-2015/images/chuck-threshold.png" target="_blank"><img src="/Users/Ivelisse/Dropbox/eip/EIP-REVISION-VERANO/Arrays/SimpleImageEditor/simpleimageeditor-Edited-NO-Solutions-July-2015/images/chuck-threshold.png" alt="chuck-threshold.png" style="max-width:100%;"></a></p>
  925. <p><strong>Figura 4.</strong> Imagen original e imagen luego de aplicar la función <code>ThresholdFilter</code>.</p>
  926. </li>
  927. </ol>
  928. <hr>
  929. <hr>
  930. <h2>
  931. <a id="user-content-entrega" class="anchor" href="#entrega" aria-hidden="true"><span class="octicon octicon-link"></span></a>Entrega</h2>
  932. <p>Utiliza "Entrega" en Moodle para entregar el archivo <code>filter.cpp</code> que contiene las funciones <code>GreyScale</code> y <code>Threshold</code>. Recuerda utilizar buenas prácticas de programación, incluir el nombre de los programadores y documentar tu programa.</p>
  933. <hr>
  934. <hr>
  935. <h2>
  936. <a id="user-content-apéndice-buenas-prácticas-al-escribir-pseudocódigos" class="anchor" href="#ap%C3%A9ndice-buenas-pr%C3%A1cticas-al-escribir-pseudoc%C3%B3digos" aria-hidden="true"><span class="octicon octicon-link"></span></a>Apéndice: Buenas prácticas al escribir pseudocódigos</h2>
  937. <ol>
  938. <li>Provee una descripción de los datos de entrada y salida</li>
  939. <li>Enumera los pasos</li>
  940. <li>Usa estructuras de repetición y decisión comunes: <code>if, else, for, while</code>
  941. </li>
  942. <li>Indenta los bloques de pasos que están dentro de una estructura de repetición o decisión, "Python-style"</li>
  943. <li>No necesitas declarar los tipos de las variables pero si debes inicializarlas. Esto es especialmente importante para contadores y acumuladores</li>
  944. <li>Recuerda que el propósito de un pseudocódigo es que un humano lo pueda entender.</li>
  945. </ol>
  946. <p><strong>Ejemplo:</strong></p>
  947. <pre><code>Input: n, a positive integer
  948. Output: true if n is prime, false otherwise
  949. ---------------------------------------------------------
  950. 1. for i = 3 to n / 2
  951. 2. if n % i == 0:
  952. 3. return false
  953. 4. return true
  954. </code></pre>
  955. <hr>
  956. <hr>
  957. <h2>
  958. <a id="user-content-referencias" class="anchor" href="#referencias" aria-hidden="true"><span class="octicon octicon-link"></span></a>Referencias</h2>
  959. <p>[1] <a href="http://www.willamette.edu/%7Egorr/classes/GeneralGraphics/imageFormats/24bits.gif">http://www.willamette.edu/~gorr/classes/GeneralGraphics/imageFormats/24bits.gif</a></p>
  960. <p>[2] <a href="http://doc.qt.io/qt-4.8/qimage.html">http://doc.qt.io/qt-4.8/qimage.html</a>.</p>
  961. <hr>
  962. <hr>
  963. <hr>
  964. <p><a href="#markdown-header-arrays-simple-image-editor">English</a> | <a href="#markdown-header-arreglos-editor-de-imagenes-simple">Español</a></p>
  965. <h1>
  966. <a id="user-content-arrays---simple-image-editor" class="anchor" href="#arrays---simple-image-editor" aria-hidden="true"><span class="octicon octicon-link"></span></a>Arrays - Simple Image Editor</h1>
  967. <p><a href="/Users/Ivelisse/Dropbox/eip/EIP-REVISION-VERANO/Arrays/SimpleImageEditor/simpleimageeditor-Edited-NO-Solutions-July-2015/images/main1.png" target="_blank"><img src="/Users/Ivelisse/Dropbox/eip/EIP-REVISION-VERANO/Arrays/SimpleImageEditor/simpleimageeditor-Edited-NO-Solutions-July-2015/images/main1.png" alt="main1.png" style="max-width:100%;"></a>
  968. <a href="/Users/Ivelisse/Dropbox/eip/EIP-REVISION-VERANO/Arrays/SimpleImageEditor/simpleimageeditor-Edited-NO-Solutions-July-2015/images/main2.png" target="_blank"><img src="/Users/Ivelisse/Dropbox/eip/EIP-REVISION-VERANO/Arrays/SimpleImageEditor/simpleimageeditor-Edited-NO-Solutions-July-2015/images/main2.png" alt="main2.png" style="max-width:100%;"></a>
  969. <a href="/Users/Ivelisse/Dropbox/eip/EIP-REVISION-VERANO/Arrays/SimpleImageEditor/simpleimageeditor-Edited-NO-Solutions-July-2015/images/main3.png" target="_blank"><img src="/Users/Ivelisse/Dropbox/eip/EIP-REVISION-VERANO/Arrays/SimpleImageEditor/simpleimageeditor-Edited-NO-Solutions-July-2015/images/main3.png" alt="main3.png" style="max-width:100%;"></a></p>
  970. <p>Arrays help us to store and work with groups of data of the same type. The data is stored in consecutive memory spaces which can be accessed by using the name of the array and indexes or subscripts that indicate the position where the data is stored. Repetition structures provide us a simple way of accessing the data within an array. In today's laboratory experience you will design and implement simple algorithms for image processing to practice the use of nested loops to manipulate bi-dimensional arrays.</p>
  971. <h2>
  972. <a id="user-content-objectives" class="anchor" href="#objectives" aria-hidden="true"><span class="octicon octicon-link"></span></a>Objectives</h2>
  973. <ol>
  974. <li><p>Practice the access and manipulation of data in an array.</p></li>
  975. <li><p>Apply nested loops to implement simple image processing algorithms.</p></li>
  976. <li><p>Use arithmetic expressions to transform colors in pixels.</p></li>
  977. <li><p>Access pixels in an image and break them down into their red, blue, and green components.</p></li>
  978. </ol>
  979. <h2>
  980. <a id="user-content-pre-lab-1" class="anchor" href="#pre-lab-1" aria-hidden="true"><span class="octicon octicon-link"></span></a>Pre-Lab:</h2>
  981. <p>Before coming to the laboratory session you should have:</p>
  982. <ol>
  983. <li><p>Acquired one or more files with a colored image in one of the following formats: <code>tiff, jpg, png</code>.</p></li>
  984. <li><p>Reviewed the basic concepts related to repetition structures and nested loops.</p></li>
  985. <li><p>Become familiar with the basic functions in <code>QImage</code> to manipulate the pixels in the images.</p></li>
  986. <li><p>Studied the concepts and instructions for the laboratory session.</p></li>
  987. <li><p>Taken the Pre-Lab quiz available through the course’s Moodle portal.</p></li>
  988. </ol>
  989. <hr>
  990. <hr>
  991. <h2>
  992. <a id="user-content-image-editing" class="anchor" href="#image-editing" aria-hidden="true"><span class="octicon octicon-link"></span></a>Image editing</h2>
  993. <p>In this laboratory experience, you will work with various concepts and basic skills of image editing. We have provided a simple graphical user interface that allows the user to load an image and invert it vertically and horizontally. Your task is to create and implement a function to convert the colored image into an image with gray tones, and another function that converts the colored image into a black and white image.</p>
  994. <h3>
  995. <a id="user-content-pixels" class="anchor" href="#pixels" aria-hidden="true"><span class="octicon octicon-link"></span></a>Pixels</h3>
  996. <p>The smallest element in an image is called a <em>pixel</em>. This unit consists of a single color. Since each color is a combination of tones for the primary red, green and blue colors, it is coded as an unsigned integer whose bytes represent the tones of red, green and blue of the pixel (Figure 1). This combination is called the color's <em>RGB</em> which is an acronym for "Red-Green-Blue". For example, a pure red pixel has an RGB representation of <code>0x00ff0000</code>, while a white pixel has an RGB representation of <code>0x00FFFFFF</code> (since the color white is a combination of tones of red, green and blue in all of their intensity).</p>
  997. <hr>
  998. <p><a href="/Users/Ivelisse/Dropbox/eip/EIP-REVISION-VERANO/Arrays/SimpleImageEditor/simpleimageeditor-Edited-NO-Solutions-July-2015/images/figure1.png" target="_blank"><img src="/Users/Ivelisse/Dropbox/eip/EIP-REVISION-VERANO/Arrays/SimpleImageEditor/simpleimageeditor-Edited-NO-Solutions-July-2015/images/figure1.png" alt="figure1.png" style="max-width:100%;"></a></p>
  999. <p><strong>Figure 1.</strong> Bit distribution for the tones of red, green and blue in an RGB representation. Each tone can have values between 0x00 (the eight bits in 0) and (0xFF (the 8 bits in 1).</p>
  1000. <hr>
  1001. <p><code>Qt</code> uses the <code>QRgb</code> type to represent <code>RGB</code> values. Using certain functions that are described below we can obtains the red, green and blue components of the <code>QRgb</code> value of the pixel and manipulate the images.</p>
  1002. <h3>
  1003. <a id="user-content-library" class="anchor" href="#library" aria-hidden="true"><span class="octicon octicon-link"></span></a>Library</h3>
  1004. <p>In today's laboratory experience you will use the <code>QImage</code> class. This class permits access to the data in the pixels of an image to manipulate it. The documentation for the <code>QImage</code> class can be found in <a href="http://doc.qt.io/qt-4.8/qimage.html">http://doc.qt.io/qt-4.8/qimage.html</a>.</p>
  1005. <p>The code provided in this project contains the following objects of the <code>QImage</code> class:</p>
  1006. <ul>
  1007. <li>
  1008. <code>originalImage</code> // contains the information of the original image that you will edit</li>
  1009. <li> <code>editedImage</code> // will contain the edited image</li>
  1010. </ul>
  1011. <p>The objects of the <code>QImage</code> class have the following methods that will be useful for today's laboratory experience:</p>
  1012. <ul>
  1013. <li>
  1014. <code>width()</code> // returns the integer value for the image's width</li>
  1015. <li>
  1016. <code>height()</code> // returns the integer value for the image's height</li>
  1017. <li>
  1018. <code>pixel(i, j)</code> // returns the <code>QRgb</code> for the pixel in position <code>(i,j)</code>
  1019. </li>
  1020. <li>
  1021. <code>setPixel(i,j, pixel)</code> // modifies the value for the pixel in position <code>(i,j)</code> to the value of pixel <code>QRgb</code>
  1022. </li>
  1023. </ul>
  1024. <p>The following functions are useful to work with data of type <code>QRgb</code>:</p>
  1025. <ul>
  1026. <li>
  1027. <code>qRed(pixel)</code> // returns the tone for the pixel's red color</li>
  1028. <li>
  1029. <code>qGreen(pixel)</code> // returns the tone for the pixel's green color</li>
  1030. <li>
  1031. <code>qBlue(pixel)</code> // returns the tone for the pixel's blue color</li>
  1032. <li>
  1033. <code>qRgb(int red, int green, int blue)</code> // returns the <code>QRgb</code> pixel composed of the red, green and blue values received.</li>
  1034. </ul>
  1035. <h4>
  1036. <a id="user-content-examples" class="anchor" href="#examples" aria-hidden="true"><span class="octicon octicon-link"></span></a>Examples:</h4>
  1037. <ol>
  1038. <li>
  1039. <p><code>QRgb myRgb = qRgb(0xff, 0x00, 0xff);</code>: Assigns the value <code>0xff00ff</code> to <code>myRgb</code> which represents the color <a href="/Users/Ivelisse/Dropbox/eip/EIP-REVISION-VERANO/Arrays/SimpleImageEditor/simpleimageeditor-Edited-NO-Solutions-July-2015/images/figure2.png" target="_blank"><img src="/Users/Ivelisse/Dropbox/eip/EIP-REVISION-VERANO/Arrays/SimpleImageEditor/simpleimageeditor-Edited-NO-Solutions-July-2015/images/figure2.png" alt="figure2.png" style="max-width:100%;"></a></p>
  1040. <p>Notice that the value <code>0xff00ff</code> represents the values <code>0xff</code>, <code>0x0</code>, and <code>0xff</code>, that correspond to the red, green and blue components in <code>myRgb</code>.</p>
  1041. </li>
  1042. <li>
  1043. <p>If the following <code>4 x 4</code> image of pixels represents the object <code>originalImage</code>,</p>
  1044. <p><a href="/Users/Ivelisse/Dropbox/eip/EIP-REVISION-VERANO/Arrays/SimpleImageEditor/simpleimageeditor-Edited-NO-Solutions-July-2015/images/ejemplo.png" target="_blank"><img src="/Users/Ivelisse/Dropbox/eip/EIP-REVISION-VERANO/Arrays/SimpleImageEditor/simpleimageeditor-Edited-NO-Solutions-July-2015/images/ejemplo.png" alt="ejemplo.png" style="max-width:100%;"></a></p>
  1045. <p>then <code>originalImage.pixel(2,1)</code> returns the <code>rgb</code> value that represents the color blue ( <code>0x0000ff</code>).</p>
  1046. </li>
  1047. <li>
  1048. <p>The following instruction assigns the color red to the pixel in position <code>(2,3)</code> in the edited image:</p>
  1049. <p><code>editedImage.setPixel(2,3,qRgb(0xff,0x00,0x00));</code>.</p>
  1050. </li>
  1051. <li>
  1052. <p>The following instruction assigns to <code>greenContent</code> the value of the green tone that is contained in the pixel <code>(1,1)</code> of <code>originalImage</code>:</p>
  1053. <p><code>int greenContent = qGreen(originalImage.pixel(1,1));</code>.</p>
  1054. </li>
  1055. <li><p>The following program creates an object of the <code>QImage</code> class and prints the red, green and blue components of the pixel in the center of the image. The image used is the one specified within the parenthesis during the creation of the object, that is, the file <code>chuck.png</code></p></li>
  1056. </ol>
  1057. <hr>
  1058. <div class="highlight highlight-cpp"><pre>#<span class="pl-k">include</span> <span class="pl-s"><span class="pl-pds">&lt;</span>QImage<span class="pl-pds">&gt;</span></span>
  1059. #<span class="pl-k">include</span> <span class="pl-s"><span class="pl-pds">&lt;</span>iostream<span class="pl-pds">&gt;</span></span>
  1060. <span class="pl-k">using</span> <span class="pl-k">namespace</span> <span class="pl-en">std</span><span class="pl-k">;</span>
  1061. <span class="pl-k">int</span> <span class="pl-en">main</span>() {
  1062. QImage <span class="pl-smi">myImage</span>(“/Users/rarce/Downloads/chuck.<span class="pl-smi">png</span>”);
  1063. QRgb centralPixel;
  1064. centralPixel = myImage.<span class="pl-c1">pixel</span>(myImage.<span class="pl-c1">width</span>() / <span class="pl-c1">2</span>, myImage.<span class="pl-c1">height</span>() / <span class="pl-c1">2</span>);
  1065. cout &lt;&lt; hex;
  1066. cout &lt;&lt; “The red, green <span class="pl-k">and</span> blue components of the middle pixel are: “
  1067. &lt;&lt; <span class="pl-c1">qRed</span>(centralPixel) &lt;&lt; “, “
  1068. &lt;&lt; <span class="pl-c1">qGreen</span>(centralPixel) &lt;&lt; “, “
  1069. &lt;&lt; <span class="pl-c1">qBlue</span>(centralPixel) &lt;&lt; endl;
  1070. <span class="pl-k">return</span> <span class="pl-c1">0</span>;
  1071. }</pre></div>
  1072. <hr>
  1073. <hr>
  1074. <h2>
  1075. <a id="user-content-laboratory-session" class="anchor" href="#laboratory-session" aria-hidden="true"><span class="octicon octicon-link"></span></a>Laboratory Session:</h2>
  1076. <p>In today's laboratory experience you will design and implement simple image processing algorithms to practice the use of nested loops and the manipulation of bi-dimensional arrays.</p>
  1077. <h3>
  1078. <a id="user-content-exercise-1-understand-the-provided-code" class="anchor" href="#exercise-1-understand-the-provided-code" aria-hidden="true"><span class="octicon octicon-link"></span></a>Exercise 1: Understand the provided code</h3>
  1079. <h4>
  1080. <a id="user-content-instructions" class="anchor" href="#instructions" aria-hidden="true"><span class="octicon octicon-link"></span></a>Instructions</h4>
  1081. <ol>
  1082. <li><p>Load the Qt project called <code>SimpleImageEditor</code> by double-clicking on the <code>SimpleImageEditor.pro</code> file in the <code>Documents/eip/Arrays-SimpleImageEditor</code> folder of your computer. You may also go to <code>http://bitbucket.org/eip-uprrp/arrays-simpleimageeditor</code> to download the <code>Arrays-SimpleImageEditor</code> folder to your computer.</p></li>
  1083. <li>
  1084. <p>The code that we provide creates the interface in Figure 2.</p>
  1085. <hr>
  1086. <p><a href="/Users/Ivelisse/Dropbox/eip/EIP-REVISION-VERANO/Arrays/SimpleImageEditor/simpleimageeditor-Edited-NO-Solutions-July-2015/images/figure3.png" target="_blank"><img src="/Users/Ivelisse/Dropbox/eip/EIP-REVISION-VERANO/Arrays/SimpleImageEditor/simpleimageeditor-Edited-NO-Solutions-July-2015/images/figure3.png" alt="figure3.png" style="max-width:100%;"></a></p>
  1087. <p><strong>Figura 2.</strong> Interface del editor de imágenes.</p>
  1088. <hr>
  1089. </li>
  1090. <li>
  1091. <p>You will be working with the <code>filter.cpp</code> file. Study the <code>HorizontalFlip</code> function in the <code>filter.cpp</code> file so you understand how it operates.</p>
  1092. <p>In the following exercises you will be mainly using the objects <code>originalImage</code> and <code>editedImage</code> of the <code>QImage</code> class. What do you think is the purpose for the <code>pixel</code> variable?</p>
  1093. </li>
  1094. <li>
  1095. <p>The provided code already has the the functionality of the buttons in the graphical user interface programmed. You do NOT have to change anything in this code but we provide the following explanations so you can know a little about how the buttons work. In the <code>mainwindow.cpp</code> file, the <code>lblOriginalImage</code> and <code>lblEditedImage</code> objects correspond to the parts of the interface that identify the original image and the processed image. The buttons</p>
  1096. <ul>
  1097. <li><code>btnLoadImage</code></li>
  1098. <li><code>btnSaveImage</code></li>
  1099. <li><code>btnInvertThreshold</code></li>
  1100. <li><code>btnFlipImageHorizontally</code></li>
  1101. <li><code>btnFlipImageVertically</code></li>
  1102. <li><code>btnGreyScaleFilter</code></li>
  1103. <li>
  1104. <code>btnRevertImage</code> </li>
  1105. </ul>
  1106. <p>are connected to functions so when a button in the interface is pressed, a certain task is carried out. For example, when you press the <code>LoadImage</code> button, a window will appear for you to select the file with the image you want to edit, which when read, the image is assigned to <code>originalImage</code>. The slider <code>thresholdSlider</code> can assume values between 0 and 255.</p>
  1107. </li>
  1108. <li><p>Compile and run the program. Test the buttons for <code>Load New Image</code> and <code>Flip Image Horizontally</code> with the images that you brought so you can validate if the buttons are working.</p></li>
  1109. </ol>
  1110. <h3>
  1111. <a id="user-content-exercise-2-convert-a-colored-image-to-an-image-with-gray-tones" class="anchor" href="#exercise-2-convert-a-colored-image-to-an-image-with-gray-tones" aria-hidden="true"><span class="octicon octicon-link"></span></a>Exercise 2: Convert a colored image to an image with gray tones</h3>
  1112. <p>Image grayscale is an operation that is used to convert a colored image to an image with only tones of gray. To make this conversion the following formula is used in each pixel:</p>
  1113. <p><code>gray = (red * 11 + green * 16 + blue * 5)/32 ;</code></p>
  1114. <p>where <code>red</code>, <code>green</code> and <code>blue</code> are the values for the tones of the red, green and blue colors in the pixel of the original colored image, and <code>gray</code> will be the assigned color to the red, green, and blue colors in the pixel of the edited image. That is,</p>
  1115. <p><code>editedImage.setPixel( i, j, qRgb(gray, gray, gray) )</code>.</p>
  1116. <h4>
  1117. <a id="user-content-instructions-1" class="anchor" href="#instructions-1" aria-hidden="true"><span class="octicon octicon-link"></span></a>Instructions</h4>
  1118. <ol>
  1119. <li><p>Using pseudocode, express the algorithm to convert a colored image to an image with only gray tones. The appendix in this document contains some advice about good techniques for writing pseudocode.</p></li>
  1120. <li>
  1121. <p>Complete the <code>GreyScale</code> function in the <code>filter.cpp</code> file to implement the grayscale algorithm. The function should produce a result similar to that in Figure 3, where the image on the left is the original image and the one on the right is the edited image.</p>
  1122. <hr>
  1123. <p><a href="/Users/Ivelisse/Dropbox/eip/EIP-REVISION-VERANO/Arrays/SimpleImageEditor/simpleimageeditor-Edited-NO-Solutions-July-2015/images/chuck-color.png" target="_blank"><img src="/Users/Ivelisse/Dropbox/eip/EIP-REVISION-VERANO/Arrays/SimpleImageEditor/simpleimageeditor-Edited-NO-Solutions-July-2015/images/chuck-color.png" alt="chuck-color.png" style="max-width:100%;"></a>
  1124. <a href="/Users/Ivelisse/Dropbox/eip/EIP-REVISION-VERANO/Arrays/SimpleImageEditor/simpleimageeditor-Edited-NO-Solutions-July-2015/images/chuck-gris.png" target="_blank"><img src="/Users/Ivelisse/Dropbox/eip/EIP-REVISION-VERANO/Arrays/SimpleImageEditor/simpleimageeditor-Edited-NO-Solutions-July-2015/images/chuck-gris.png" alt="chuck-gris.png" style="max-width:100%;"></a></p>
  1125. <p><strong>Figure 3.</strong> Original image and image after applying the <code>GreyScale</code> function.</p>
  1126. <hr>
  1127. </li>
  1128. </ol>
  1129. <h3>
  1130. <a id="user-content-exercise-3-convert-a-colored-image-to-a-black-and-white-image-thresholding" class="anchor" href="#exercise-3-convert-a-colored-image-to-a-black-and-white-image-thresholding" aria-hidden="true"><span class="octicon octicon-link"></span></a>Exercise 3: Convert a colored image to a black and white image ("Thresholding")</h3>
  1131. <p>Thresholding es an operation that can be used to convert a colored image to an image in black and white. To make this conversion we must decide which colors of the original image will be converted to white pixels and which to black. One simple way of deciding this is to compute the average of the red, green and blue components of each pixel. If the average is smaller than the threshold value, then we change the pixel to black; if not, it's changed to white.</p>
  1132. <h4>
  1133. <a id="user-content-instructions-2" class="anchor" href="#instructions-2" aria-hidden="true"><span class="octicon octicon-link"></span></a>Instructions</h4>
  1134. <ol>
  1135. <li><p>Using pseudocode, express the thresholding algorithm. Assume that you will use the slider's value as the threshold.</p></li>
  1136. <li><p>In the program, if the <code>chkboxThreshold</code> box is marked, the <code>applyThresholdFilter</code> function is invoked. The <code>applyThresholdFilter</code> function is also invoked each time that the value of the slider is changed.</p></li>
  1137. <li><p>Complete the <code>ThresholdFilter</code> function so it implements the threshold algorithm in the colored image using the slider's value as the threshold. If the implementation is correct, the image on the right should be the original image but in black and white. The threshold value is a parameter of the <code>ThresholdFilter</code> function. The code provided in <code>mainwindow.h</code> has the constants <code>BLACK</code> and <code>WHITE</code> defined with their hexadecimal values; you can take advantage of this and use them in your code.</p></li>
  1138. <li><p>The boolean parameter <code>invertColor</code> will be <code>true</code> if the option to invert the colors has been selected. Write the code so that the white and black colors are inverted if <code>invertColor</code> is <code>true</code>.</p></li>
  1139. <li>
  1140. <p>Test the program with different images and different threshold values.</p>
  1141. <hr>
  1142. <p><a href="/Users/Ivelisse/Dropbox/eip/EIP-REVISION-VERANO/Arrays/SimpleImageEditor/simpleimageeditor-Edited-NO-Solutions-July-2015/images/chuck-color.png" target="_blank"><img src="/Users/Ivelisse/Dropbox/eip/EIP-REVISION-VERANO/Arrays/SimpleImageEditor/simpleimageeditor-Edited-NO-Solutions-July-2015/images/chuck-color.png" alt="chuck-color.png" style="max-width:100%;"></a>
  1143. <a href="/Users/Ivelisse/Dropbox/eip/EIP-REVISION-VERANO/Arrays/SimpleImageEditor/simpleimageeditor-Edited-NO-Solutions-July-2015/images/chuck-threshold.png" target="_blank"><img src="/Users/Ivelisse/Dropbox/eip/EIP-REVISION-VERANO/Arrays/SimpleImageEditor/simpleimageeditor-Edited-NO-Solutions-July-2015/images/chuck-threshold.png" alt="chuck-threshold.png" style="max-width:100%;"></a></p>
  1144. <p><strong>Figure 4.</strong> Original image and image after applying the <code>ThresholdFilter</code> function.</p>
  1145. <hr>
  1146. <hr>
  1147. </li>
  1148. </ol>
  1149. <h2>
  1150. <a id="user-content-deliverables" class="anchor" href="#deliverables" aria-hidden="true"><span class="octicon octicon-link"></span></a>Deliverables</h2>
  1151. <p>Use "Deliverables" in Moodle to upload the <code>filter.cpp</code> file that contains the <code>GreyScale</code> and <code>Threshold</code> functions. Remember to use good programming techniques, include the names of the programmers involved, and to document your program.</p>
  1152. <hr>
  1153. <hr>
  1154. <h2>
  1155. <a id="user-content-appendix-good-techniques-for-writing-pseudocode" class="anchor" href="#appendix-good-techniques-for-writing-pseudocode" aria-hidden="true"><span class="octicon octicon-link"></span></a>Appendix: Good techniques for writing pseudocode</h2>
  1156. <ol>
  1157. <li>Provide a description of the input and output data</li>
  1158. <li>Enumerate the steps</li>
  1159. <li>Use common repetition and decision structures: <code>if, else, for, while</code>
  1160. </li>
  1161. <li>Indent the blocks of steps that are inside of a decision or repetition structure, "Python-style"</li>
  1162. <li>You do not need to declare the types of variables but you should initialize them. This is especially important for counters and accumulators</li>
  1163. <li>Remember that the purpose of pseudocode is so a human can understand it.</li>
  1164. </ol>
  1165. <p><strong>Example:</strong></p>
  1166. <pre><code>Input: n, a positive integer
  1167. Output: true if n is prime, false otherwise
  1168. ---------------------------------------------------------
  1169. 1. for i = 3 to n / 2
  1170. 2. if n % i == 0:
  1171. 3. return false
  1172. 4. return true
  1173. </code></pre>
  1174. <hr>
  1175. <hr>
  1176. <h2>
  1177. <a id="user-content-references" class="anchor" href="#references" aria-hidden="true"><span class="octicon octicon-link"></span></a>References</h2>
  1178. <p>[1] <a href="http://www.willamette.edu/%7Egorr/classes/GeneralGraphics/imageFormats/24bits.gif">http://www.willamette.edu/~gorr/classes/GeneralGraphics/imageFormats/24bits.gif</a></p>
  1179. <p>[2] <a href="http://doc.qt.io/qt-4.8/qimage.html">http://doc.qt.io/qt-4.8/qimage.html</a>.</p>
  1180. </article></body></html>