Guest User

Untitled

a guest
Jan 18th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. class Image
  2. def initialize (data)
  3. @data = data
  4. end
  5.  
  6. #write a method that loops through the existing 2D array and finds the
  7. #location of the existing ones. The location of the the existing ones
  8. #needs to be stored into memory so they can be iterated over and the
  9. #exiting cells around them can be altered.
  10.  
  11. def find_the_ones
  12.  
  13. found_ones = []
  14.  
  15. data.each_with_index do
  16. #find the row postion
  17.  
  18. data.each_with_index do
  19. #find the column position
  20.  
  21. if position == 1
  22.  
  23. #find a way to store both the row and the column of a number
  24. #If a 1 is found, store it in the found_ones array
  25.  
  26. #write a method that will blur or transform the ones
  27.  
  28. def blur
  29.  
  30. #if clause to change the value (above) a found one
  31. #if clause to change the value to the (left) of a found oune
  32. #if clause to change the value to the (right) of a found one
  33. #if clause to change the value to the (bottom) of a found one
  34.  
  35. #have to determine if item postion is on an edge
  36. #row/column index of -1 for last row or column
  37.  
  38.  
  39.  
  40. end
  41.  
  42. def output_image
  43. @data.each do |array|
  44. puts array.join
  45. end
  46. end
  47. end
  48.  
  49.  
  50.  
  51. image = Image.new([
  52. [0, 0, 0, 0],
  53. [0, 1, 0, 0],
  54. [0, 0, 0, 1],
  55. [0, 0, 0, 0]
  56. ])
  57.  
  58. image.output_image
  59. #output new blurrled image below old blurred image
Add Comment
Please, Sign In to add comment