fork download
  1. #include<stdio.h>
  2. #include"./Graphics.h"
  3. #include"./Image.h"
  4. #define IE 480
  5. #define JE 640
  6.  
  7. void DisplayColorImage(int **R,int **G,int **B, int**Y)
  8. {
  9. int i,j,x;
  10. double a,b,c;
  11. a = 0.6;
  12. b = 0.2;
  13. c = 0.2;
  14.  
  15.  
  16. for(i=0 ; i < IE ; i++){
  17. for(j = 0 ; j < JE ; j++){
  18. Y[i][j]=a*R[i][j]+b*G[i][j]+c*B[i][j];
  19.  
  20.  
  21. /* 画像の表示 */
  22. GSetColor(Y[i][j],Y[i][j],Y[i][j]);
  23. GPSet(j,i);
  24. }
  25. }
  26. }
  27.  
  28.  
  29. void Ptile(int **Y)
  30. {
  31. int i,j;
  32. for(i=0; i < IE; i++){
  33. for(j=0; j < JE; j++){
  34. if(Y[i][j]>120){
  35. Y[i][j] = 1;
  36. }else{
  37. Y[i][j] = 0;
  38. }
  39. GSetColor(Y[i][j]*255,Y[i][j]*255,Y[i][j]*255);
  40. GPSet(j,i);
  41. }
  42. }
  43. }
  44.  
  45.  
  46. void Shuushuku(int **F, int **F2){
  47. int i,j,s,IE,JE;
  48. for(i = 0; i < IE; i++){
  49. for(j =0; j < JE; j++){
  50. if(F[i][j] == 0){
  51. F[i][j] = 0;
  52. F2[i][j] = 0;
  53. }else{
  54. F[i][j] = 1;
  55. F2[i][j] = 1;
  56. }
  57. }
  58. }
  59. for(i = 1; i < IE; i++){
  60. for(j = 1; j < JE; j++){
  61. if(F[i-1][j] == 1 && F2[i][j-1] == 1 &&
  62. F[i][j+1] == 1 && F2[i-1][j] == 1){
  63. F[i][j] = 1;
  64. }else{
  65. F2[i][j] = 0;
  66. }
  67. }
  68. }
  69. for(i = 0; i < IE; i++){
  70. for(j = 0; j < JE; j++){
  71. F2[i][j]=F[i][j];
  72. }
  73. }
  74. for(i = 1; i < IE; i++){
  75. for(j = 1; j < JE; j++){
  76. if(F2[i][j]==1){
  77. F[i-1][j] = 1;
  78. F[i][j-1] = 1;
  79. F[i][j+1] = 1;
  80. F[i+1][j] = 1;
  81. }
  82. }
  83. }
  84. for(i = 0; i < IE; i++){
  85. for(j = 0; j < JE; j++){
  86. if(F[i][j] == 1){
  87. s=255;
  88. }else{
  89. s=0;
  90. }
  91. GSetColor(s, s, s);
  92. GPSet(j,i);
  93. }
  94. }
  95. }
  96.  
  97.  
  98. void DisplayColorHairetu(int **R,int **G,int **B, int**Y)
  99. {
  100. int i,j,k,n;
  101.  
  102. double a,b,c;
  103. a = 0.6;
  104. b = 0.2;
  105. c = 0.2;
  106.  
  107. int hairetu[256];
  108.  
  109. for(n = 0; n < 256; n++){
  110.  
  111. hairetu[n] = 0;
  112. }
  113.  
  114. for(i=0 ; i < IE ; i++){
  115. for(j = 0 ; j < JE ; j++){
  116.  
  117. Y[i][j]=a*R[i][j]+b*G[i][j]+c*B[i][j];
  118. hairetu[Y[i][j]]=hairetu[Y[i][j]] + 1 ;
  119. }
  120. }
  121.  
  122. for(k=0 ; k < 256 ; k++){
  123. printf("%d %d\n", k,hairetu[k]);
  124. }
  125.  
  126. }
  127.  
  128. main(){
  129. int i,j;
  130. int **R, **G, **B, **Y, **F, **F2;
  131.  
  132. R = IAllocImage(640,480);
  133. G = IAllocImage(640,480);
  134. B = IAllocImage(640,480);
  135. Y = IAllocImage(640,480);
  136. F = IAllocImage(640,480);
  137. F2 = IAllocImage(640,480);
  138.  
  139. GInit(640,480);
  140. ILoadPpmImage("kadai1.ppm" ,R,G,B);
  141. DisplayColorImage(R,G,B,Y);
  142. DisplayColorHairetu(R,G,B,Y);
  143. GWaitLoop();
  144. Ptile(Y);
  145. GWaitLoop();
  146. Shuushuku(F,F2);
  147. GWaitLoop();
  148. }
  149.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:2:23: error: ./Graphics.h: No such file or directory
prog.cpp:3:20: error: ./Image.h: No such file or directory
prog.cpp: In function ‘void DisplayColorImage(int**, int**, int**, int**)’:
prog.cpp:22: error: ‘GSetColor’ was not declared in this scope
prog.cpp:23: error: ‘GPSet’ was not declared in this scope
prog.cpp:9: warning: unused variable ‘x’
prog.cpp: In function ‘void Ptile(int**)’:
prog.cpp:39: error: ‘GSetColor’ was not declared in this scope
prog.cpp:40: error: ‘GPSet’ was not declared in this scope
prog.cpp: In function ‘void Shuushuku(int**, int**)’:
prog.cpp:47: error: expected unqualified-id before numeric constant
prog.cpp:91: error: ‘GSetColor’ was not declared in this scope
prog.cpp:92: error: ‘GPSet’ was not declared in this scope
prog.cpp: At global scope:
prog.cpp:128: warning: ISO C++ forbids declaration of ‘main’ with no type
prog.cpp: In function ‘int main()’:
prog.cpp:132: error: ‘IAllocImage’ was not declared in this scope
prog.cpp:139: error: ‘GInit’ was not declared in this scope
prog.cpp:140: error: ‘ILoadPpmImage’ was not declared in this scope
prog.cpp:143: error: ‘GWaitLoop’ was not declared in this scope
prog.cpp:129: warning: unused variable ‘i’
prog.cpp:129: warning: unused variable ‘j’
stdout
Standard output is empty