KYRALEKOS

Untitled

Mar 24th, 2020
305
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.68 KB | None | 0 0
  1. https://drive.google.com/drive/folders/1D190XNu7W02Dgc8FCwpEeI-2-WKgu4KY?usp=sharing
  2.  
  3. https://drive.google.com/drive/folders/1D190XNu7W02Dgc8FCwpEeI-2-WKgu4KY?usp=sharing
  4. /*
  5. ------------------------------------------------------------
  6. ANSI C IMAGE PROCESSING TEMPLATE USING DIP LIBRARY
  7. by D.K. Iakovidis
  8. ------------------------------------------------------------
  9. */
  10.  
  11. #include <stdio.h>
  12. #include <stdlib.h>
  13. #include <math.h>
  14. #include "dip.h"
  15.  
  16. unsigned char **processImage(unsigned char **inputImage,unsigned char **inputImage2, int rows, int columns);
  17.  
  18. int main(void)
  19. {
  20. unsigned char *inputFilename1 = "mri221x279.raw",
  21. *inputFilename2 = "petGrey221x279.raw",
  22. *outputFilename = "result_img.raw";
  23. int rows = 221,
  24. columns = 279;
  25.  
  26. unsigned char **inputImage1, **outputImage,**inputImage2;
  27.  
  28. inputImage1 = allocateImage(rows, columns);
  29. inputImage2 = allocateImage(rows, columns);
  30. inputImage1 = loadImage(inputFilename1, rows, columns);
  31. inputImage2 = loadImage(inputFilename2, rows, columns);
  32.  
  33. outputImage = processImage(inputImage1,inputImage2, rows, columns);
  34. saveImage(outputFilename, outputImage, rows, columns);
  35. deallocateImage(inputImage1, rows);
  36. deallocateImage(inputImage2, rows);
  37. deallocateImage(outputImage, rows);
  38.  
  39. return 0;
  40. }
  41.  
  42.  
  43. unsigned char **processImage(unsigned char **inputImage1,unsigned char **inputImage2, int rows, int columns)
  44. {
  45. int i,j;
  46.  
  47. float mesh_timh;
  48. unsigned char **outputImage = allocateImage(rows, columns);
  49.  
  50. for (i = 0; i < rows; i++)
  51. {
  52. for (j = 0; j < columns; j++)
  53. {
  54. mesh_timh=(inputImage1[i][j]+inputImage2[i][j])/2;
  55. if(mesh_timh>255){
  56. mesh_timh=255;}
  57. if(mesh_timh<0){
  58. mesh_timh=0}
  59. }
  60. outputImage[i][j] = (unsigned char)mesh_timh;
  61. }
  62. }
  63. return outputImage;
  64. }
  65.  
  66. ___________________________________________________________
  67. /*
  68. ------------------------------------------------------------
  69. ANSI C IMAGE PROCESSING TEMPLATE USING DIP LIBRARY
  70. by D.K. Iakovidis
  71. ------------------------------------------------------------
  72. */
  73.  
  74. #include <stdio.h>
  75. #include <stdlib.h>
  76. #include <math.h>
  77. #include "dip.h"
  78.  
  79. unsigned char **processImage(unsigned char **inputImage, int rows, int columns);
  80.  
  81. int main(void)
  82. {
  83. unsigned char *inputFilename = "chest339x339.raw",
  84. *outputFilename = "chest339x339.raw";
  85. int rows = 339,
  86. columns = 339;
  87.  
  88. unsigned char **inputImage, **outputImage;
  89.  
  90. inputImage = allocateImage(rows, columns);
  91.  
  92. inputImage = loadImage(inputFilename, rows, columns);
  93. outputImage = processImage(inputImage, rows, columns);
  94. saveImage(outputFilename, outputImage, rows, columns);
  95. deallocateImage(inputImage, rows);
  96. deallocateImage(outputImage, rows);
  97.  
  98. return 0;
  99. }
  100.  
  101.  
  102. unsigned char **processImage(unsigned char **inputImage, int rows, int columns)
  103. {
  104. int i,j;
  105. unsigned char **outputImage = allocateImage(rows, columns);
  106.  
  107. for (i = 0; i < rows; i++)
  108. {
  109. for (j = 0; j < columns; j++)
  110. {
  111. if(j<columns/2){
  112. outputImage[i][j] = 255;
  113. }else{
  114. outputImage[i][j] = 0;
  115. }
  116. if(inputImage[i][j]>170){
  117. inputImage[i][j] = 255;
  118. }else{
  119. inputImage[i][j] = 0;
  120. }
  121. outputImage[i][j] =outputImage[i][j]&(255-inputImage[i][j]); // h 3d eikona me xor ^ vgainei h st
  122. }
  123. }
  124. return outputImage;
  125. }
Add Comment
Please, Sign In to add comment