<commit_before>(ns mosaic.tile
  (import java.io.File)
  (import java.awt.Color)
  (import java.awt.image.BufferedImage)
  (import java.awt.image.Raster)
  (import javax.imageio.ImageIO)
  (import com.mortennobel.imagescaling.ResampleOp))

(defn test-mosaic []
  (ImageIO/read
   (File. "test/resources/image.jpg")))

(defn rescale [x y ^BufferedImage b]
  (. (ResampleOp. x y) (filter b nil)))<commit_msg>I can get Rasters for tile regions in an image<commit_after>(ns mosaic.tile
  (import java.io.File)
  (import java.awt.Color)
  (import java.awt.image.BufferedImage)
  (import java.awt.image.Raster)
  (import javax.imageio.ImageIO)
  (import com.mortennobel.imagescaling.ResampleOp)
  (import java.awt.Rectangle))

(defn test-mosaic []
  (ImageIO/read
   (File. "test/resources/image.jpg")))

(defn rescale [x y ^BufferedImage b]
  (. (ResampleOp. x y) (filter b nil)))

(defn tile-rects [n x y]
  "divide dimensions x,y into Rectangles of size n
   omitting regions that are not complete tiles"
  (for [a (range 0 (- x n -1) n) b (range 0 (- y n -1) n)]
    (Rectangle. a b n n)))

(defn tile-rasters [n ^BufferedImage b]
  "divide buffered image into rasters of size n"
  (let [h (.getHeight b)
	w (.getWidth b)]
    (map #(.getData b %) (tile-rects n w h))))


{'fraction_non_alphanumeric': 0.14420803782505912, 'fraction_numerical': 0.0031520882584712374, 'mean_word_length': 3.618181818181818, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1415343', 'n_tokens_mistral': 497, 'n_tokens_neox': 479, 'n_words': 139}