Repository: hi-paris/deepdespeckling (language: python)

Issue:
added github tests



Discussion / hints:

Fix patch:
diff --git a/README.md b/README.md
index 517c6f5..9b12a32 100644
--- a/README.md
+++ b/README.md
@@ -1,47 +1,28 @@
 # deepdespeckling Synthetic Aperture Radar (SAR) images with Pytorch
 
-
-Based on the work of Emanuele Dalsasso, post-doctoral researcher at CNAM and Telecom Paris.
-
-Speckle fluctuations seriously limit the interpretability of synthetic aperture radar (SAR) images. This package provides despeckling methods that can highly improve the quality and interpretability of SAR images.
-
+Speckle fluctuations seriously limit the interpretability of synthetic aperture radar (SAR) images. This package provides despeckling methods that can highly improve the quality and interpretability of SAR images. Both Stripmap and Spotlight operations are handled by this package. 
+ 
 The package contains both test and train parts, wether you wish to despeckle a single pic (test) or use our model to build or improve your own.
 
-To know more about the researcher's work : https://arxiv.org/abs/2110.13148
-
 To get a test function using Tensorflow's framework : https://gitlab.telecom-paris.fr/ring/MERLIN/-/blob/master/README.md
 
-
+[![PyPI version](https://badge.fury.io/py/deepdespeckling.svg)](https://badge.fury.io/py/deepdespeckling)
 [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
-<img src="icons/pypi.svg" class="center">
-<img src="icons/doc.svg" class="center">
-<img src="icons/build.svg" class="center">
-
-![Python](https://img.shields.io/badge/python-3670A0?style=for-the-badge&logo=python&logoColor=ffdd54)
 
 # Installation
 
-Install merlin by running in the command prompt :
-
-```console
-pip install -i https://test.pypi.org/pypi/ --extra-index-url https://pypi.org/simple deepdespeckling --no-cache-dir
-```
-
-# Initialization for merlin package.
+Install deepdespeckling by running in the command prompt :
 
 ```python
-import deepdespeckling
+pip install deepdespeckling
 ```
 
-
-
-
 # Authors
 
 
 * [Emanuele Dalsasso](https://perso.telecom-paristech.fr/dalsasso/) (Researcher at Telecom Paris)
-* [Youcef Kemiche](https://engineeringteam.hi-paris.fr/about-us-2/) (Hi! PARIS engineer)
-* [Pierre Blanchard](https://engineeringteam.hi-paris.fr/about-us-2/) (Hi! PARIS engineer)
+* [Youcef Kemiche](https://www.linkedin.com/in/youcef-kemiche-3095b9174/) (Hi! PARIS Machine Learning Research Engineer)
+* [Pierre Blanchard](https://www.linkedin.com/in/pierre-blanchard-28245462/) (Hi! PARIS Engineer)
 
 
 # Use cases
@@ -52,25 +33,28 @@ The package offers you 3 different methods for despeckling your SAR images: the
 1) I have a high-resolution SAR image and I want to apply the despeckling function to the whole of it:
 
 ```python
-from deepdespeckling.merlin.test.spotlight import despeckle
+from deepdespeckling.merlin.test.spotlight import despeckle_st
 
 image_path="path/to/cosar/image"
 destination_directory="path/where/to/save/results"
 model_weights_path="path/to/model/weights"
 
-despeckle(image_path,destination_directory,model_weights_path=model_weights_path)
+despeckle_st(image_path,destination_directory,model_weights_path=model_weights_path)
 ```
+Noisy image             |  Denoised image
+:----------------------:|:-------------------------:
+![](img/entire/noisy.png)  |  ![](img/entire/denoised.png)
 
 2) I have a high-resolution SAR image but I only want to apply the despeckling function to a specific area for which I know the coordinates:
 ```python
-from deepdespeckling.merlin.test.spotlight import despeckle_from_coordinates
+from deepdespeckling.merlin.test.spotlight import despeckle_from_coordinates_st
 
 image_path="path/to/cosar/image"
 destination_directory="path/where/to/save/results"
 model_weights_path="path/to/model/weights"
 coordinates_dictionnary = {'x_start':2600,'y_start':1000,'x_end':3000,'y_end':1200}
 
-despeckle_from_coordinates(image_path, coordinates_dict, destination_directory, model_weights_path)
+despeckle_from_coordinates_st(image_path, coordinates_dict, destination_directory, model_weights_path)
 ````
 
 Noisy image             |  Denoised image
@@ -79,15 +63,16 @@ Noisy image             |  Denoised image
 
 3) I have a high-resolution SAR image but I want to apply the despeckling function to an area I want to select with a crop:
 ```python
-from deepdespeckling.merlin.test.spotlight import despeckle_from_crop
+from deepdespeckling.merlin.test.spotlight import despeckle_from_crop_st
 
 image_path="path/to/cosar/image"
 destination_directory="path/where/to/save/results"
 model_weights_path="path/to/model/weights"
 fixed = True "(it will crop a 256*256 image from the position of your click)" or False "(you will draw free-handly the area of your interest)"
 
-despeckle_from_crop(image_path, destination_directory, model_weights_path, fixed=False)
+despeckle_from_crop_st(image_path, destination_directory, model_weights_path, fixed=False)
 ```
+
 * The cropping tool: Just select an area and press "q" when you are satisfied with the crop !
 
 <p align="center">
@@ -100,6 +85,10 @@ Noisy cropped image                     |           Denoised cropped image
 :-----------------------------------------------------------:|:------------------------------------------:
  <img src="img/crop/noisy_test_image_data.png" width="100%"> | <img src="img/crop/denoised_test_image_data.png" width="1000%">
 
+you can use the same features for stripmap images by importing : 
+```python
+from deepdespeckling.merlin.test.stripmap import despeckle_from_crop_sp,despeckle_sp,despeckle_from_coordinates_sp
+```
 ### Train
 
 1) I want to train my own model from scratch:
@@ -107,6 +96,7 @@ Noisy cropped image                     |           Denoised cropped image
 from deepdespeckling.merlin.train.train import create_model, fit_model
 nb_epoch=1
 
+# schedule the learning rate
 lr = 0.001 * np.ones([nb_epoch])
 lr[6:20] = lr[0]/10
 lr[20:] = lr[0]/100
@@ -130,6 +120,7 @@ from merlinsar.train.model import Model
 
 nb_epoch=1
 
+# schedule the learning rate
 lr = 0.001 * np.ones([nb_epoch])
 lr[6:20] = lr[0]/10
 lr[20:] = lr[0]/100
@@ -156,3 +147,7 @@ fit_model(model,lr,nb_epoch,training_set_directory,validation_set_directory,samp
 # FAQ
 
 * Please contact us at [engineer@hi-paris.fr](engineer@hi-paris.fr)
+
+# References
+
+[1] DALSASSO, Emanuele, DENIS, Loïc, et TUPIN, Florence. [As if by magic: self-supervised training of deep despeckling networks with MERLIN](https://arxiv.org/pdf/2110.13148.pdf). IEEE Transactions on Geoscience and Remote Sensing, 2021, vol. 60, p. 1-13.
diff --git a/deepdespeckling/merlin/train/sample/denoised_lely0_epoch_1.png b/deepdespeckling/merlin/train/sample/denoised_lely0_epoch_1.png
deleted file mode 100644
index 7766b6b..0000000
Binary files a/deepdespeckling/merlin/train/sample/denoised_lely0_epoch_1.png and /dev/null differ
diff --git a/img/entire/denoised.png b/img/entire/denoised.png
new file mode 100644
index 0000000..c1e40f0
Binary files /dev/null and b/img/entire/denoised.png differ
diff --git a/img/entire/noisy.png b/img/entire/noisy.png
new file mode 100644
index 0000000..8a6f46f
Binary files /dev/null and b/img/entire/noisy.png differ
diff --git a/setup.py b/setup.py
index 0402cae..de02cee 100644
--- a/setup.py
+++ b/setup.py
@@ -11,7 +11,7 @@
 test_requirements = [ ]
 
 setup(
-    author="emanuele dalsasso, youcef kemiche, pierre blanchard",
+    author="Emanuele Dalsasso, Youcef Kemiche, Pierre Blanchard",
     author_email='y.kemiche06@hotmail.com',
     python_requires='>=3.6',
     classifiers=[
@@ -45,6 +45,6 @@
     test_suite='tests',
     tests_require=test_requirements,
     url='https://github.com/ykemiche/deepdespeckling',
-    version='0.3.8',
+    version='0.1.0',
     zip_safe=False,
 )


Test patch:
diff --git a/.github/workflows/test _37.yml b/.github/workflows/test _37.yml
index 10b8545..e0f1fda 100644
--- a/.github/workflows/test _37.yml
+++ b/.github/workflows/test _37.yml
@@ -55,4 +55,4 @@ jobs:
         # make dist
         # pip install dist/*
         # python setup.py develop
-        pip install -i https://test.pypi.org/pypi/ --extra-index-url https://pypi.org/simple deepdespeckling --no-cache-dir
+        pip install deepdespeckling 
diff --git a/.github/workflows/test_36.yml b/.github/workflows/test_36.yml
deleted file mode 100644
index 511f04c..0000000
--- a/.github/workflows/test_36.yml
+++ /dev/null
@@ -1,58 +0,0 @@
-name: pytesting
-
-on:
-  push:
-    # branches-ignore:
-    #   - "main"
-# #    branches: [ main ]
-  schedule:
-    - cron: '0 0 1 * *'
-# pull_request:
-#    branches:
-#      - '*'
-
-jobs:
-  run:
-    runs-on: ${{ matrix.os }}
-    strategy:
-      matrix:
-        # os: [ubuntu-latest]
-        os: [ubuntu-latest, windows-latest,macos-latest]
-        python: ['3.6']
-    env:
-      OS: ${{ matrix.os }}
-      PYTHON: ${{ matrix.python }}
-    steps:
-    - uses: actions/checkout@v1
-    - name: Set up Python 3.6
-      uses: actions/setup-python@v1
-      with:
-        python-version: ${{ matrix.python }}
-    - name: Install dependencies
-      run: |
-        # python -m pip install --upgrade pip
-        # pip install -r requirements_dev.txt
-    # - name: Lint with flake8
-    #   run: |
-    #     pip install flake8
-    #     # stop the build if there are Python syntax errors or undefined names
-    #     flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
-    #     # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
-    #     flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
-    # - name: Test with pytest
-    #   run: |
-    #     pip install pytest
-    #     pytest -v --cov=structured-predictions --cov-report=html
-
-
-    # - name: Build and compile
-    #   run: |
-    #     make dist
-    #     python setup.py develop
-
-    - name: Build and compile
-      run: |
-        # make dist
-        # pip install dist/*
-        # python setup.py develop
-        pip install -i https://test.pypi.org/pypi/ --extra-index-url https://pypi.org/simple deepdespeckling --no-cache-dir
\ No newline at end of file
diff --git a/.github/workflows/test_38.yml b/.github/workflows/test_38.yml
index 3258bb4..fca6fc8 100644
--- a/.github/workflows/test_38.yml
+++ b/.github/workflows/test_38.yml
@@ -55,4 +55,4 @@ jobs:
         # make dist
         # pip install dist/*
         # python setup.py develop
-        pip install -i https://test.pypi.org/pypi/ --extra-index-url https://pypi.org/simple deepdespeckling --no-cache-dir
+        pip install deepdespeckling
diff --git a/.github/workflows/test_39.yml b/.github/workflows/test_39.yml
index c6518d8..ba7ecac 100644
--- a/.github/workflows/test_39.yml
+++ b/.github/workflows/test_39.yml
@@ -55,4 +55,4 @@ jobs:
         # make dist
         # pip install dist/*
         # python setup.py develop
-        pip install -i https://test.pypi.org/pypi/ --extra-index-url https://pypi.org/simple deepdespeckling --no-cache-dir
+        pip install deepdespeckling 
diff --git a/deepdespeckling/merlin/test/saved_model/model.pth b/deepdespeckling/merlin/test/saved_model/spotlight.pth
similarity index 100%
rename from deepdespeckling/merlin/test/saved_model/model.pth
rename to deepdespeckling/merlin/test/saved_model/spotlight.pth
diff --git a/deepdespeckling/merlin/test/saved_model/stripmap.pth b/deepdespeckling/merlin/test/saved_model/stripmap.pth
new file mode 100644
index 0000000..652d0fe
Binary files /dev/null and b/deepdespeckling/merlin/test/saved_model/stripmap.pth differ
diff --git a/deepdespeckling/merlin/test/spotlight.py b/deepdespeckling/merlin/test/spotlight.py
index 918994e..8a67a3a 100644
--- a/deepdespeckling/merlin/test/spotlight.py
+++ b/deepdespeckling/merlin/test/spotlight.py
@@ -17,8 +17,8 @@
 this_dir, this_filename = os.path.split(__file__)
 
 
-def despeckle(image_path, destination_directory, stride_size=64,
-              model_weights_path=os.path.join(this_dir, "saved_model", "model.pth"), patch_size=256):
+def despeckle_st(image_path, destination_directory, stride_size=64,
+              model_weights_path=os.path.join(this_dir, "saved_model", "spotlight.pth"), patch_size=256):
     """ Description
             ----------
             Runs a test instance by calling the test function defined in model.py on a few samples
@@ -43,10 +43,15 @@ def despeckle(image_path, destination_directory, stride_size=64,
     for f in filelist:
         os.remove(f)
 
-    image_data = cos2mat(image_path)
 
-    p = Path(image_path)
-    np.save(test_data + '/' + p.stem, image_data)
+    # check the extension of the file
+    if Path(image_path).suffix==".npy":
+        image_data=np.load(image_path)
+    else:
+        image_data = cos2mat(image_path) 
+
+    np.save(test_data+'/test_image_data.npy',image_data)
+
 
     print(
         "[*] Start testing on real data. Working directory: %s. Collecting data from %s and storing test results in %s" % (
@@ -59,8 +64,8 @@ def despeckle(image_path, destination_directory, stride_size=64,
                   stride=stride_size, patch_size=patch_size)
 
 
-def despeckle_from_coordinates(image_path, coordinates_dict, destination_directory, stride_size=64,
-                               model_weights_path=os.path.join(this_dir, "saved_model", "model.pth"), patch_size=256):
+def despeckle_from_coordinates_st(image_path, coordinates_dict, destination_directory, stride_size=64,
+                               model_weights_path=os.path.join(this_dir, "saved_model", "spotlight.pth"), patch_size=256):
     """ Description
             ----------
             Runs a test instance by calling the test function defined in model.py on a few samples
@@ -90,10 +95,13 @@ def despeckle_from_coordinates(image_path, coordinates_dict, destination_directo
     for f in filelist:
         os.remove(f)
 
-    image_data = cos2mat(image_path)
+    # check the extension of the file
+    if Path(image_path).suffix==".npy":
+        image_data=np.load(image_path)
+    else:
+        image_data = cos2mat(image_path) 
 
-    p = Path(image_path)
-    np.save(test_data + '/' + p.stem, image_data[x_start:x_end, y_start:y_end, :])
+    np.save(test_data+'/test_image_data.npy',image_data[x_start:x_end,y_start:y_end,:])
 
     print(
         "[*] Start testing on real data. Working directory: %s. Collecting data from %s and storing test results in %s" % (
@@ -105,8 +113,8 @@ def despeckle_from_coordinates(image_path, coordinates_dict, destination_directo
                   stride=stride_size, patch_size=patch_size)
 
 
-def despeckle_from_crop(image_path, destination_directory, stride_size=64,
-                        model_weights_path=os.path.join(this_dir, "saved_model", "model.pth"), patch_size=256,
+def despeckle_from_crop_st(image_path, destination_directory, stride_size=64,
+                        model_weights_path=os.path.join(this_dir, "saved_model", "spotlight.pth"), patch_size=256,
                         fixed=True):
     print('value ofd fixed in despeckle from crop', fixed)
     """ The despeckling function with an integrated cropping tool made with OpenCV.
@@ -152,10 +160,10 @@ def despeckle_from_crop(image_path, destination_directory, stride_size=64,
 
     # CROPPING OUR PNG AND REFLECT THE CROP ON REAL AND IMAG
     if fixed:
-        print('FIXED')
+        print('Fixed mode selected')
         crop_fixed(image_png, image_data_real, image_data_imag, destination_directory, test_data)
     else:
-        print('FREE')
+        print('Free mode selected')
         crop(image_png, image_data_real, image_data_imag, destination_directory, test_data)
 
     image_data_real_cropped = np.load(test_data + '\\image_data_real_cropped.npy')
diff --git a/deepdespeckling/merlin/test/stripmap.py b/deepdespeckling/merlin/test/stripmap.py
new file mode 100644
index 0000000..9b61764
--- /dev/null
+++ b/deepdespeckling/merlin/test/stripmap.py
@@ -0,0 +1,190 @@
+import torch
+
+from deepdespeckling.merlin.test.model import *
+from deepdespeckling.merlin.test.utils import *
+from deepdespeckling.merlin.test.model_test import *
+import os
+from glob import glob
+import pathlib
+from pathlib import Path
+
+import numpy as np
+from deepdespeckling.merlin.test.load_cosar import cos2mat
+
+M = 10.089038980848645
+m = -1.429329123112601
+
+this_dir, this_filename = os.path.split(__file__)
+
+
+def despeckle_sp(image_path, destination_directory, stride_size=64,
+              model_weights_path=os.path.join(this_dir, "saved_model", "stripmap.pth"), patch_size=256):
+              
+    """ Description
+            ----------
+            Runs a test instance by calling the test function defined in model.py on a few samples
+
+            Parameters
+            ----------
+            denoiser : an object
+
+            Returns
+            ----------
+
+    """
+
+    denoiser = Denoiser()
+
+    if not os.path.exists(destination_directory + '/processed_image'):
+        os.mkdir(destination_directory + '/processed_image')
+
+    test_data = destination_directory + '/processed_image'
+
+    filelist = glob(os.path.join(test_data, "*"))
+    for f in filelist:
+        os.remove(f)
+        
+     # check the extension of the file
+    if Path(image_path).suffix==".npy":
+        image_data=np.load(image_path)
+    else:
+        image_data = cos2mat(image_path) 
+
+    np.save(test_data+'/test_image_data.npy',image_data)
+
+    print(
+        "[*] Start testing on real data. Working directory: %s. Collecting data from %s and storing test results in %s" % (
+            os.getcwd(), destination_directory, destination_directory))
+
+    test_files = glob((test_data + '/*.npy'))
+    print(test_files)
+
+    denoiser.test(test_files, model_weights_path, save_dir=destination_directory,
+                  stride=stride_size, patch_size=patch_size)
+
+
+def despeckle_from_coordinates_sp(image_path, coordinates_dict, destination_directory, stride_size=64,
+                               model_weights_path=os.path.join(this_dir, "saved_model", "stripmap.pth"), patch_size=256):
+    """ Description
+            ----------
+            Runs a test instance by calling the test function defined in model.py on a few samples
+
+            Parameters
+            ----------
+            denoiser : an object
+
+            Returns
+            ----------
+
+    """
+
+    x_start = coordinates_dict["x_start"]
+    x_end = coordinates_dict["x_end"]
+    y_start = coordinates_dict["y_start"]
+    y_end = coordinates_dict["y_end"]
+
+    denoiser = Denoiser()
+
+    if not os.path.exists(destination_directory + '/processed_image'):
+        os.mkdir(destination_directory + '/processed_image')
+
+    test_data = destination_directory + '/processed_image'
+
+    filelist = glob(os.path.join(test_data, "*"))
+    for f in filelist:
+        os.remove(f)
+
+   
+   # check the extension of the file
+    if Path(image_path).suffix==".npy":
+        image_data=np.load(image_path)
+    else:
+        image_data = cos2mat(image_path) 
+
+    np.save(test_data+'/test_image_data.npy',image_data[x_start:x_end,y_start:y_end,:])
+
+    
+    print(
+        "[*] Start testing on real data. Working directory: %s. Collecting data from %s and storing test results in %s" % (
+            os.getcwd(), destination_directory, destination_directory))
+
+    test_files = glob((test_data + '/*.npy'))
+    print(test_files)
+    denoiser.test(test_files, model_weights_path, save_dir=destination_directory,
+                  stride=stride_size, patch_size=patch_size)
+
+
+def despeckle_from_crop_sp(image_path, destination_directory, stride_size=64,
+                        model_weights_path=os.path.join(this_dir, "saved_model", "stripmap.pth"), patch_size=256,
+                        fixed=True):
+    print('value ofd fixed in despeckle from crop', fixed)
+    """ The despeckling function with an integrated cropping tool made with OpenCV.
+    The ideal choice if you need to despeckle only a certain area of your high-res image. Results are saved in the
+    directory provided in the 'destination directory'
+            Parameters
+            ----------
+            image_path: string
+            the path leading to the image to be despceckled
+            destination_directory: string
+            path leading to the results folder
+            stride_size: integer or tuple
+            stride of the autoencoder
+            model_weights_path: string
+            path leading to the weights of our pre-trained model. Value by default is our weights.
+            patch_size: integer
+            Area size of the sub-image to be processed. Value by default is 256.
+            height: integer
+            Height of the image. Value by default is 256.
+            width: integer
+            Width of the image. Value by default is 256.
+            fixed: bool
+            If True, crop size is limited to 256*256
+            Returns
+            ----------
+            None
+    """
+
+    denoiser = Denoiser()
+
+    if not os.path.exists(destination_directory + '\\processed_image'):
+        os.mkdir(destination_directory + '\\processed_image')
+
+    test_data = destination_directory + '\\processed_image'
+
+    filelist = glob(os.path.join(test_data, "*"))
+    for f in filelist:
+        os.remove(f)
+
+    # FROM IMAGE PATH RETRIEVE PNG, NPY, REAL , IMAG, THRESHOLD, FILENAME
+    image_png, image_data, image_data_real, image_data_imag, threshold, filename = get_info_image(image_path,
+                                                                                                  destination_directory)
+
+    # CROPPING OUR PNG AND REFLECT THE CROP ON REAL AND IMAG
+    if fixed:
+        print('Fixed mode selected')
+        crop_fixed(image_png, image_data_real, image_data_imag, destination_directory, test_data)
+    else:
+        print('Free mode selected')
+        crop(image_png, image_data_real, image_data_imag, destination_directory, test_data)
+
+    image_data_real_cropped = np.load(test_data + '\\image_data_real_cropped.npy')
+    store_data_and_plot(image_data_real_cropped, threshold, test_data + '\\image_data_real_cropped.npy')
+    image_data_imag_cropped = np.load(test_data + '\\image_data_imag_cropped.npy')
+    store_data_and_plot(image_data_imag_cropped, threshold, test_data + '\\image_data_imag_cropped.npy')
+
+    image_data_real_cropped = image_data_real_cropped.reshape(image_data_real_cropped.shape[0],
+                                                              image_data_real_cropped.shape[1], 1)
+    image_data_imag_cropped = image_data_imag_cropped.reshape(image_data_imag_cropped.shape[0],
+                                                              image_data_imag_cropped.shape[1], 1)
+
+    p = Path(image_path)
+    np.save(test_data + '/' + p.stem + '_cropped',
+            np.concatenate((image_data_real_cropped, image_data_imag_cropped), axis=2))
+
+    print(
+        "[*] Start testing on real data. Working directory: %s. Collecting data from %s and storing test results in %s" % (
+            os.getcwd(), destination_directory, destination_directory))
+    print('path to npy or not',test_data + '/' + p.stem + '_cropped.npy')
+    test_files = glob((test_data + '/' + p.stem + '_cropped.npy'))
+    denoiser.test(test_files, model_weights_path, save_dir=destination_directory,
+                  stride=stride_size, patch_size=patch_size)
\ No newline at end of file
diff --git a/deepdespeckling/merlin/test/utils.py b/deepdespeckling/merlin/test/utils.py
index a8df2ab..8ab1a60 100644
--- a/deepdespeckling/merlin/test/utils.py
+++ b/deepdespeckling/merlin/test/utils.py
@@ -7,6 +7,7 @@
 from PIL import Image
 import numpy as np
 from numpy import asarray
+import os
 
 
 # DEFINE PARAMETERS OF SPECKLE AND NORMALIZATION FACTOR
@@ -298,7 +299,6 @@ def mouse_crop_fixed(event, x, y, flags, param):
         elif event == cv2.EVENT_LBUTTONUP:
             # record the ending (x, y) coordinates
             x_end, y_end = x, y
-            print('before permutation', x_start, y_start, x_end, y_end)
             # case crop is done bottom right - top left : WORKS
             if x_start > x_end and y_start > y_end:
                 print('Case n2 from bottom right to top left')
@@ -310,7 +310,6 @@ def mouse_crop_fixed(event, x, y, flags, param):
 
                 y_start = tempystart - 32
                 y_end = tempystart
-                print('after permutation', x_start, y_start, x_end, y_end)
 
             elif x_start > x_end and y_start < y_end:
                 print('Case n3 top right to botton left')
@@ -322,7 +321,6 @@ def mouse_crop_fixed(event, x, y, flags, param):
 
                 x_end = tempxstart
                 y_end = tempystart + 32
-                print('after permutation', x_start, y_start, x_end, y_end)
 
             elif x_start < x_end and y_start > y_end:
                 print('Case n4 bottom left to top right')
@@ -333,13 +331,11 @@ def mouse_crop_fixed(event, x, y, flags, param):
                 y_start = tempystart - 32
                 x_end = tempxstart + 32
                 y_end = tempystart
-                print('after permutation', x_start, y_start, x_end, y_end)
 
             else:
                 print('general case')
                 x_end = x_start + 32
                 y_end = y_start + 32
-                print('after permutation', x_start, y_start, x_end, y_end)
 
             refPoint = [(x_start, y_start), (x_end, y_end)]
             print('refPoint', refPoint)
@@ -435,7 +431,6 @@ def mouse_crop(event, x, y, flags, param):
         elif event == cv2.EVENT_LBUTTONUP:
             # record the ending (x, y) coordinates
             x_end, y_end = x, y
-            print('before permutation', x_start, y_start, x_end, y_end)
             # case crop is done bottom right - top left : WORKS
             if x_start > x_end and y_start > y_end:
                 print('Case n2 from bottom right to top left')
@@ -446,7 +441,6 @@ def mouse_crop(event, x, y, flags, param):
                 tempy = y_start
                 y_start = y_end
                 y_end = tempy
-                print('after permutation', x_start, y_start, x_end, y_end)
 
             elif x_start > x_end and y_start < y_end:
                 print('Case n3 top right to botton left')
@@ -459,7 +453,6 @@ def mouse_crop(event, x, y, flags, param):
                 y_start = tempystart
                 x_end = tempxstart
                 y_end = tempyend
-                print('after permutation', x_start, y_start, x_end, y_end)
 
             elif x_start < x_end and y_start > y_end:
                 print('Case n4 bottom left to top right')
@@ -472,10 +465,6 @@ def mouse_crop(event, x, y, flags, param):
                 y_start = tempyend
                 x_end = tempxend
                 y_end = tempystart
-                print('after permutation', x_start, y_start, x_end, y_end)
-
-            else:
-                print('after permutation', x_start, y_start, x_end, y_end)
 
             ## cropping is finished
             cv2.rectangle(image, (x_start, y_start), (x_end, y_end), (255, 0, 0), 2)
@@ -539,7 +528,13 @@ def get_info_image(image_path, destination_directory):
             None
 
     """
-    image_data = cos2mat(image_path)
+    
+    filename, file_extension = os.path.splitext(image_path)
+    if file_extension==".npy":
+        image_data = np.load(image_path)
+
+    else:
+        image_data = cos2mat(image_path)
 
     # GET THE TWO PARTS
     image_data_real = image_data[:, :, 0]