Skip to content

Instantly share code, notes, and snippets.

@kenmazaika
Created July 5, 2015 21:18
Show Gist options
  • Save kenmazaika/86ec928772721ea37c78 to your computer and use it in GitHub Desktop.
Save kenmazaika/86ec928772721ea37c78 to your computer and use it in GitHub Desktop.
class Image
attr_accessor :output_image
def initialize(array)
@input_image = array
end
def blur
@a_rows = @input_image.length
@a_columns = @input_image[1].length
@output_image = Array.new(@a_rows) {Array.new(@a_columns, 0)}
@input_image.each_with_index do |row, row_index|
row.each_with_index do |pixel, col_index|
# this iterates through every single square one at a time.
# pixel is the pixel value
# col_index is the column index
# row_index is the row index
# @output_image[row_index][col_index] = 1 # modify the output image
end
end
@output_image
end
end
a1 = [[1, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 1],
]
array = Image.new(a1)
p array.blur
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment