Parcourir la source

Add of ICA diff metric

Jérôme BUISINE il y a 5 ans
Parent
commit
3d248e5a9e

+ 15 - 15
analysis/svd_entropy_analysis.ipynb

@@ -89,7 +89,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 16,
+   "execution_count": 5,
    "metadata": {},
    "outputs": [],
    "source": [
@@ -124,7 +124,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 17,
+   "execution_count": 6,
    "metadata": {},
    "outputs": [],
    "source": [
@@ -146,7 +146,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 6,
+   "execution_count": 7,
    "metadata": {},
    "outputs": [],
    "source": [
@@ -177,26 +177,26 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 7,
+   "execution_count": 8,
    "metadata": {},
    "outputs": [],
    "source": [
-    "current_dict = dict_sdb_d\n",
+    "current_dict = dict_appart\n",
     "interval = (30, 200)"
    ]
   },
   {
    "cell_type": "code",
-   "execution_count": 8,
+   "execution_count": 9,
    "metadata": {},
    "outputs": [
     {
      "name": "stdout",
      "output_type": "stream",
      "text": [
-      "../fichiersSVD_light/SdbDroite/SdB2_D_00020.png\n",
-      "../fichiersSVD_light/SdbDroite/SdB2_D_00400.png\n",
-      "../fichiersSVD_light/SdbDroite/SdB2_D_00950.png\n"
+      "../fichiersSVD_light/Appart1opt02/appartAopt_00020.png\n",
+      "../fichiersSVD_light/Appart1opt02/appartAopt_00200.png\n",
+      "../fichiersSVD_light/Appart1opt02/appartAopt_00900.png\n"
      ]
     }
    ],
@@ -207,14 +207,14 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 28,
+   "execution_count": 12,
    "metadata": {},
    "outputs": [],
    "source": [
     "first_image = zones_data[0][1]\n",
     "entropy_contribution_data = []\n",
     "\n",
-    "sv = processing.get_LAB_L_SVD_s(zone)\n",
+    "sv = processing.get_LAB_L_SVD_s(first_image)\n",
     "sv = utils.normalize_arr(sv)\n",
     "entropy = utils.get_entropy(sv)\n",
     "\n",
@@ -226,7 +226,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 29,
+   "execution_count": 13,
    "metadata": {},
    "outputs": [
     {
@@ -242,7 +242,7 @@
        "        92,  93,  94,  95,  96,  97,  98,  99, 100])"
       ]
      },
-     "execution_count": 29,
+     "execution_count": 13,
      "metadata": {},
      "output_type": "execute_result"
     }
@@ -253,7 +253,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 30,
+   "execution_count": 14,
    "metadata": {},
    "outputs": [
     {
@@ -269,7 +269,7 @@
        "       109, 108, 107, 106, 105, 104, 103, 102, 101])"
       ]
      },
-     "execution_count": 30,
+     "execution_count": 14,
      "metadata": {},
      "output_type": "execute_result"
     }

Fichier diff supprimé car celui-ci est trop grand
+ 355 - 0
analysis/svd_ica_scenes_analysis.ipynb


+ 1 - 1
modules/utils/config.py

@@ -35,7 +35,7 @@ cycle_scenes_indices            = ['E', 'I']
 normalization_choices           = ['svd', 'svdn', 'svdne']
 zones_indices                   = np.arange(16)
 
-metric_choices_labels           = ['lab', 'mscn', 'low_bits_2', 'low_bits_3', 'low_bits_4', 'low_bits_5', 'low_bits_6','low_bits_4_shifted_2', 'sub_blocks_stats', 'sub_blocks_area', 'sub_blocks_stats_reduced', 'sub_blocks_area_normed', 'mscn_var_4', 'mscn_var_16', 'mscn_var_64', 'mscn_var_16_max', 'mscn_var_64_max']
+metric_choices_labels           = ['lab', 'mscn', 'low_bits_2', 'low_bits_3', 'low_bits_4', 'low_bits_5', 'low_bits_6','low_bits_4_shifted_2', 'sub_blocks_stats', 'sub_blocks_area', 'sub_blocks_stats_reduced', 'sub_blocks_area_normed', 'mscn_var_4', 'mscn_var_16', 'mscn_var_64', 'mscn_var_16_max', 'mscn_var_64_max', 'ica_diff']
 
 keras_epochs                    = 500
 keras_batch                     = 32

+ 18 - 0
modules/utils/data.py

@@ -3,6 +3,7 @@ from modules.utils.config import *
 
 from PIL import Image
 from skimage import color
+from sklearn.decomposition import FastICA
 
 import numpy as np
 
@@ -202,6 +203,23 @@ def get_svd_data(data_type, block):
         indices = data.argsort()[-size:][::-1]
         data = data[indices]
 
+    if data_type == 'ica_diff':
+        current_image = metrics.get_LAB_L(block)
+
+        ica = FastICA(n_components=50)
+        ica.fit(current_image)
+
+        image_ica = ica.fit_transform(current_image)
+        image_restored = ica.inverse_transform(image_ica)
+
+        final_image = utils.normalize_2D_arr(image_restored)
+        final_image = np.array(final_image * 255, 'uint8')
+
+        sv_values = utils.normalize_arr(metrics.get_SVD_s(current_image))
+        ica_sv_values = utils.normalize_arr(metrics.get_SVD_s(final_image))
+
+        data = abs(np.arrat(sv_values) - np.array(ica_sv_values))
+
     return data
 
 def _get_mscn_variance(block, sub_block_size=(50, 50)):