Commit 9171210e authored by geoint's avatar geoint

fix

parent e70fb5ca
...@@ -26,17 +26,16 @@ class Merge(object): ...@@ -26,17 +26,16 @@ class Merge(object):
>>> Files = tools("all") #IW_SLC,IW_GRDH,MSIL1C >>> Files = tools("all") #IW_SLC,IW_GRDH,MSIL1C
>>> dir="make/" >>> dir="make/"
>>> platform='Sentinel-2' >>> platform='Sentinel-2'
>>> list_files=Files.findFilesSentinel(dir,platform,2)#4 for resample_subset.dim >>> list_files=Files.findFilesSentinel(dir,platform,4)#4 for resample_subset.dim
>>> print 'There is/are %d ' % len(list_files) + platform + ' file(s)' >>> print 'There is/are %d ' % len(list_files) + platform + ' file(s)'
>>> Read=readProduct(dir,platform) >>> Read=readProduct(dir,platform)
>>> TypeMerge="RGB" >>> TypeMerge="RGB"
>>> Mergee=Merge(TypeMerge) >>> Mergee=Merge("60",TypeMerge)
>>> for image in list_files: >>> for image in list_files:
... file = dir + image ... file = dir + image
... products = Files.search_band_combination(file, TypeMerge) ... print"Applying SubSet... ", image
... print"Applying Merge "+TypeMerge+"... ", image
... product=Read.ReadFilesSentinel(file,2)#The flag 2 ReadFiles .dim ... product=Read.ReadFilesSentinel(file,2)#The flag 2 ReadFiles .dim
... Mergee.merges(product, products,file) ... Mergee.merges(product, file)
""" """
def __init__(self,TypeMerge): def __init__(self,TypeMerge):
...@@ -54,6 +53,7 @@ class Merge(object): ...@@ -54,6 +53,7 @@ class Merge(object):
self.looks = jpy.get_type('org.esa.snap.core.datamodel.quicklooks.QuicklookGenerator') self.looks = jpy.get_type('org.esa.snap.core.datamodel.quicklooks.QuicklookGenerator')
self.File = jpy.get_type('java.io.File') self.File = jpy.get_type('java.io.File')
#def merges(self, product, file):
def merges(self, product, products,file): def merges(self, product, products,file):
"""Index Files Sentinel """Index Files Sentinel
...@@ -122,3 +122,19 @@ class Merge(object): ...@@ -122,3 +122,19 @@ class Merge(object):
output_dataset.GetRasterBand(3).WriteRaster(0, 0, xsize, ysize, values3) output_dataset.GetRasterBand(3).WriteRaster(0, 0, xsize, ysize, values3)
output_dataset = None output_dataset = None
Files = tools("all") #IW_SLC,IW_GRDH,MSIL1C
dir="make/"
platform='Sentinel-2'
list_files=Files.findFilesSentinel(dir,platform,2)#4 for resample_subset.dim
print 'There is/are %d ' % len(list_files) + platform + ' file(s)'
Read=readProduct(dir,platform)
TypeMerge="RGB"
Mergee=Merge(TypeMerge)
for image in list_files:
file = dir + image
products = Files.search_band_combination(file, TypeMerge)
print"Applying Merge "+TypeMerge+"... ", image
product=Read.ReadFilesSentinel(file,2)#The flag 2 ReadFiles .dim
#Mergee.merges(product, file)#for resample_subset.dim
Mergee.merges(product, products,file)#for .SAFE
...@@ -14,7 +14,7 @@ class tools(object): ...@@ -14,7 +14,7 @@ class tools(object):
>>> Files = tools('all') >>> Files = tools('all')
>>> dir='make' >>> dir='make'
>>> platform='Sentinel-2' >>> platform='Sentinel-2'
>>> list_files=Files.findFilesSentinel(dir,platform,1)#Find 1=.zip, 2=.SAFE, 3 and 4=.dim >>> list_files=Files.findFilesSentinel(dir,platform)
>>> print 'There is/are %d ' % len(list_files) + platform + ' file(s)' >>> print 'There is/are %d ' % len(list_files) + platform + ' file(s)'
""" """
...@@ -60,6 +60,7 @@ class tools(object): ...@@ -60,6 +60,7 @@ class tools(object):
if platform == "Sentinel-1": if platform == "Sentinel-1":
nam1=self.namfil1 nam1=self.namfil1
nam2=self.namfil2 nam2=self.namfil2
#files = [f for f in files if f.startswith(nam1) and f.endswith(ext) or f.startswith(nam2)]
if platform == "Sentinel-2": if platform == "Sentinel-2":
nam1=self.namfil3 nam1=self.namfil3
nam2=self.namfil4 nam2=self.namfil4
......
...@@ -184,9 +184,9 @@ jas_matrix_t *imgData[nChannels]; ...@@ -184,9 +184,9 @@ jas_matrix_t *imgData[nChannels];
{ {
for (unsigned int x = 0; x < width; ++x) for (unsigned int x = 0; x < width; ++x)
{ {
//int delta = max-min; float delta = max-min;
//jas_matrix_set(imgData[i], y, x, (unsigned char)(255* (data[nChannels*(y*width+x)+i]-min)/delta) ); jas_matrix_set(imgData[i], y, x, (unsigned char)(255* ((float)data[nChannels*(y*width+x)+i]-min)/delta) );
jas_matrix_set(imgData[i], y, x, (unsigned char)(255*data[nChannels*(y*width+x)+i]/(pow(2,12))) ); //jas_matrix_set(imgData[i], y, x, (unsigned char)(255*data[nChannels*(y*width+x)+i]/(pow(2,12))) );
} }
} }
} }
......
...@@ -7,21 +7,42 @@ ext=.jpg ...@@ -7,21 +7,42 @@ ext=.jpg
cd $BASEDIR cd $BASEDIR
for f in $(find . -type f -name '*.zip') for f in $(find . -type f -name '*.zip')
do do
unzip -j $f *B02.jp2 *B03.jp2 *B04.jp2 -d $OUTDIR
filepattern=$(echo $f | cut -d"_" -f6)"_"$(echo $f | cut -d"_" -f3)"_B"
filename=$OUTDIR$filepattern
echo $filename
if [ ! -e $filename"02.jp2" -o ! -e $filename"03.jp2" -o ! -e $filename"04.jp2" ]; then
unzip -n -j $f *B02.jp2 *B03.jp2 *B04.jp2 -d $OUTDIR
else
echo PASS $f
fi
cd $OUTDIR cd $OUTDIR
red=$(ls *B04.jp2 -t |head -1) red=$(ls $filepattern"04.jp2" -t |head -1)
green=$(ls *B03.jp2 -t |head -1) green=$(ls $filepattern"03.jp2" -t |head -1)
blue=$(ls *B02.jp2 -t |head -1) blue=$(ls $filepattern"02.jp2" -t |head -1)
echo "red-"$red
echo "gre-"$green
echo "blu-"$blue
# m=$(pwd) # m=$(pwd)
# red=$m/$red # red=$m/$red
# green=$m/$green # green=$m/$green
# blue=$m/$blue # blue=$m/$blue
# ./jp2ToJPGandStretch $red if [ ! -e $filepattern"04.jpg" ]; then
# ./jp2ToJPGandStretch $green jp2ToJPGandStretch $red
# ./jp2ToJPGandStretch $blue fi
if [ ! -e $filepattern"03.jpg" ]; then
jp2ToJPGandStretch $green
fi
if [ ! -e $filepattern"02.jpg" ]; then
jp2ToJPGandStretch $blue
fi
# red=$(ls *B04.jpg -t |head -1) # red=$(ls *B04.jpg -t |head -1)
# green=$(ls *B03.jpg -t |head -1) # green=$(ls *B03.jpg -t |head -1)
# blue=$(ls *B02.jpg -t |head -1) # blue=$(ls *B02.jpg -t |head -1)
...@@ -29,12 +50,16 @@ do ...@@ -29,12 +50,16 @@ do
# red=$m/$red # red=$m/$red
# green=$m/$green # green=$m/$green
# blue=$m/$blue # blue=$m/$blue
# convert $red $green $blue -combine $(OUTDIR)/$count$ext if [ ! -d "video" ]; then
mkdir video
fi
fileout=$(echo $filepattern | cut -d"_" -f2)
convert $filepattern"04.jpg" $filepattern"02.jpg" $filepattern"02.jpg" -combine video/$fileout".jpg"
# rm *.jp2 # rm *.jp2
# rm *B04.jpg # rm *B04.jpg
# rm *B03.jpg # rm *B03.jpg
# rm *B02.jpg # rm *B02.jpg
# count=$((count+1)) # count=$((count+1))
cd .. cd ..
done
done
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment