<commit_before>package neuroflow.application.processor

import java.awt.Color
import java.awt.image.BufferedImage
import java.io.File
import java.net.URL

import javax.imageio.ImageIO
import breeze.linalg.{DenseMatrix, DenseVector}
import breeze.storage.Zero
import neuroflow.common.Logs
import neuroflow.core.{Tensor3D, Tensor3DImpl}

import scala.io.Source
import scala.reflect.ClassTag

/**
  * @author bogdanski
  * @since 03.01.16
  */
object Image extends Logs {


  /**
    * Loads image from `file` or `path` and returns flattened [[DenseVector]]
    * where pixel values are normalized to be <= 1.0.
    */

  def loadRgbVector(path: String): DenseVector[Double] = loadRgbVector(new File(path))

  def loadRgbVector(file: File): DenseVector[Double] = {
    val img = ImageIO.read(file)
    val res =
      (0 until img.getHeight).flatMap { h =>
        (0 until img.getWidth).flatMap { w =>
          val c = new Color(img.getRGB(w, h))
          c.getRed / 255.0 :: c.getGreen / 255.0 :: c.getBlue / 255.0 :: Nil<commit_msg>symmetric names<commit_after>package neuroflow.application.processor

import java.awt.Color
import java.awt.image.BufferedImage
import java.io.File
import java.net.URL

import javax.imageio.ImageIO
import breeze.linalg.{DenseMatrix, DenseVector}
import breeze.storage.Zero
import neuroflow.common.Logs
import neuroflow.core.{Tensor3D, Tensor3DImpl}

import scala.io.Source
import scala.reflect.ClassTag

/**
  * @author bogdanski
  * @since 03.01.16
  */
object Image extends Logs {


  /**
    * Loads image from `file` or `path` and returns flattened [[DenseVector]]
    * where pixel values are normalized to be <= 1.0.
    */

  def loadVectorRGB(path: String): DenseVector[Double] = loadVectorRGB(new File(path))

  def loadVectorRGB(file: File): DenseVector[Double] = {
    val img = ImageIO.read(file)
    val res =
      (0 until img.getHeight).flatMap { h =>
        (0 until img.getWidth).flatMap { w =>
          val c = new Color(img.getRGB(w, h))
          c.getRed / 255.0 :: c.getGreen / 255.0 :: c.getBlue / 255.0 :: Nil
{'fraction_non_alphanumeric': 0.12077294685990338, 'fraction_numerical': 0.02318840579710145, 'mean_word_length': 3.4063829787234043, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '3403956', 'n_tokens_mistral': 730, 'n_tokens_neox': 686, 'n_words': 174}