Пример #1
0
  public static void main(String[] args) throws IOException {
    // ---Устанавливаем и инициализируем компоненты------------
    DesktopSetup.deploy();
    ImageAWT.installComponent(new RedImageAWT());
    CV.installComponent(new RedCV());

    // ---Читаем файлы-----------------------------
    File input_folder = LocalFileSystem.ApplicationHome().child("input");
    File output_folder = LocalFileSystem.ApplicationHome().child("output");

    File file_1 = input_folder.child("3.jpg");

    ColorMap color_map_1 = readImage(file_1);

    // ---Конвертируем пикчу в λ-изображение---------------
    ColoredλImage image_1 = color_map_1.getLambdaImage();
    Rectangle image_1_size = Geometry.newRectangle(color_map_1.getWidth(), color_map_1.getHeight());

    // --- Обрабатываем--------------------------
    ColoredλImage result = производная(image_1, image_1_size);

    // --- Добавим яркости
    result = bright(result);

    // --- Инвертируем ----------------
    // result = CV.invert(result); // для этого надо разкоментировать эту
    // строку убрав палки // в начале

    // --- Сохраняем результат -------------------
    File result_file = output_folder.child("result.png");
    saveResult(result, image_1_size, result_file);

    // На выходе видны артефакты сжатия
  }
Пример #2
0
  public static void main(String[] args) throws IOException {
    DesktopSetup.deploy();

    TextureSlicer.installComponent(new RedTextureSlicer());

    File input_folder = LocalFileSystem.ApplicationHome().child("input");
    File output_folder = LocalFileSystem.ApplicationHome().child("output");

    File input_file = input_folder.child("example.jpg");

    output_folder.makeFolder();
    output_folder.clearFolder();

    TextureSlicerSpecs specs = TextureSlicer.newDecompositionSpecs();
    specs.setInputFile(input_file);
    int tile_size = 256 * 2;
    int margin = TextureSlicerSpecs.MIN_TILE_SIZE / 2;
    specs.setTileWidth(tile_size - 2 * margin);
    specs.setTileHeight(tile_size - 2 * margin);
    specs.setMargin(margin);

    ID package_name = Names.newID("com.jfixby.tool.texture.slicer.example");

    specs.setNameSpacePrefix(package_name);

    specs.setOutputFolder(output_folder);

    TextureSlicingResult result = TextureSlicer.decompose(specs);
    { // Save resulting structure info
      L.d("output", result.getRasterID());
      SlicesCompositionInfo composition = result.getTilesComposition();
      SlicesCompositionsContainer container = new SlicesCompositionsContainer();
      container.content.addElement(composition);
      String data = Json.serializeToString(container).toString();

      ID sctruct_package_name = package_name.child(TextureSlicerSpecs.TILE_MAP_FILE_EXTENSION);
      String struct_pkg_name = sctruct_package_name.toString();
      File container_file = output_folder.child(struct_pkg_name);
      container_file.writeString(data);

      // com.badlogic.gdx.utils.Json j = new
      // com.badlogic.gdx.utils.Json();
      JsonValue gdx_json = new JsonReader().parse(data);
      L.d("structure:");
      L.d(gdx_json.toString());
    }
  }
  public static void main(final String[] args) throws IOException, URISyntaxException {
    DesktopSetup.deploy();
    Json.installComponent("com.jfixby.cmns.adopted.gdx.json.RedJson");

    final File words_folder = LocalFileSystem.ApplicationHome().child("words");
    final ChildrenList words_files = words_folder.listDirectChildren();
    final WordsSorter sorter = new WordsSorter(false);
    for (int i = 0; i < words_files.size(); i++) {
      final File file = words_files.getElementAt(i);
      final String file_name = file.getName();
      if (file_name.startsWith("#")) {
        continue;
      }
      L.d("reading", file_name);
      final String data = file.readToString();
      L.d("parsing", file_name);
      final WordCollectorFile content = Json.deserializeFromString(WordCollectorFile.class, data);

      final List<WordCollector> split = Collections.newList(content.values);
      L.d("   adding", split.size());
      sorter.addOthers(split);
    }
    sorter.filter(1);
    sorter.sort();

    // sorter.print();

    final Collection<WordCollector> terms_list = sorter.list();
    terms_list.print("terms_list", 0, 500);
    final Random random = new Random();

    final int EXTRACTIONS = 100;
    final int NUMBER_OF_TERMS = 8;

    for (int i = 0; ; i++) {
      final List<String> batch = Collections.newList();
      for (int k = 0; k < EXTRACTIONS; k++) {
        final String request = generateRequest(NUMBER_OF_TERMS, terms_list, random);
        batch.add(request);
      }
      batch.print("batch generated");
      for (int k = 0; k < batch.size(); k++) {
        final String request = batch.getElementAt(k);
        final String request_url = template + request.replaceAll(" ", "+");
        L.d(request, request_url);
        openUrl(request_url);
        Sys.sleep(10 * 1000);
      }
    }
  }