Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pixel counter
- #red = [255,0, 0]
- #green = [0, 255, 0]
- #blue = [0, 0, 255]
- #black = [0, 0, 0]
- #white = [255, 255, 255]
- #yellow = [255, 255, 0]
- #Define RED
- #R value must be greater 100
- #G and B values must be less than R/4
- sample = [
- [[65, 67, 23], [234, 176, 0], [143, 0, 0]],
- [[255, 30, 51], [156, 41, 38], [3, 243, 176]],
- [[255, 255, 255], [0, 0, 0], [133, 28, 13]],
- [[26, 43, 255], [48, 2, 2], [57, 89, 202]]
- ]
- i = 0
- j = 0
- k = 0
- line = 0
- redcheck = false
- greencheck = false
- bluecheck = false
- redpixelcount = 0
- pixelcount = 1
- while (i < sample.length)
- while (j < sample[i].length)
- puts "PIXEL # " + pixelcount.to_s
- red = sample[i][j][0]
- green = sample[i][j][1]
- blue = sample[i][j][2]
- r4 = red/4
- if (red >= 100 && green <= r4 && blue <= r4 )
- puts "THIS IS RED"
- redpixelcount += 1
- end
- pixelcount += 1
- j += 1
- end
- j = 0
- i += 1
- end
- puts "There are: " + (pixelcount-1).to_s + " pixels"
- puts redpixelcount.to_s + " are RED"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement