Skip to content

Instantly share code, notes, and snippets.

@isomorpheric
Created February 20, 2016 14:11
Show Gist options
  • Save isomorpheric/4502739daaac82f5b845 to your computer and use it in GitHub Desktop.
Save isomorpheric/4502739daaac82f5b845 to your computer and use it in GitHub Desktop.
# Image Blur #3
class Blur
attr_accessor :array, :blurred_array, :ones
def initialize(array)
@array = array
end
def output_image
@blurred_array.each do |row|
puts row.join(" ")
end
end
def one_finder
@ones = []
#Cycle through each pixel, store pixel in @ones if pixel == 1
@array.each.with_index do |row, row_i|
puts "row"
row.each.with_index do |pixel, col_i|
if pixel == 1
@ones << [row_i, col_i]
puts "ONE PUSHED"
end
end
end
puts "The ones are: #{@ones}. Now I'm going to type '@ones' in the IRB. It will return nil for some reason."
end
end
image = Blur.new([
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 1, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
])
image.one_finder
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment