Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
imagej-elphel
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
List
Board
Labels
Milestones
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Elphel
imagej-elphel
Commits
6894dccd
Commit
6894dccd
authored
Dec 04, 2023
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Trying to get GPS data
parent
db9a0992
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
1192 additions
and
94 deletions
+1192
-94
pom.xml
pom.xml
+29
-6
EyesisCorrections.java
.../java/com/elphel/imagej/correction/EyesisCorrections.java
+2
-2
Eyesis_Correction.java
.../java/com/elphel/imagej/correction/Eyesis_Correction.java
+117
-4
Did_ins.java
src/main/java/com/elphel/imagej/ims/Did_ins.java
+17
-0
ChangeImageResolution.java
...java/com/elphel/imagej/readers/ChangeImageResolution.java
+224
-0
DumpImageMetadata.java
...ain/java/com/elphel/imagej/readers/DumpImageMetadata.java
+239
-0
ElphelTiffReader.java
...main/java/com/elphel/imagej/readers/ElphelTiffReader.java
+0
-3
ElphelTiffWriter.java
...main/java/com/elphel/imagej/readers/ElphelTiffWriter.java
+435
-0
EyesisTiff.java
src/main/java/com/elphel/imagej/readers/EyesisTiff.java
+44
-5
QuadCLTCPU.java
...main/java/com/elphel/imagej/tileprocessor/QuadCLTCPU.java
+85
-74
No files found.
pom.xml
View file @
6894dccd
...
@@ -217,21 +217,20 @@
...
@@ -217,21 +217,20 @@
<target>
1.8
</target>
<target>
1.8
</target>
</configuration>
</configuration>
</plugin>
</plugin>
<plugin>
<plugin>
<groupId>
org.codehaus.mojo
</groupId>
<groupId>
org.codehaus.mojo
</groupId>
<artifactId>
exec-maven-plugin
</artifactId>
<artifactId>
exec-maven-plugin
</artifactId>
<version>
1.3.2
</version>
<!--$NO-MVN-MAN-VER$-->
<version>
1.3.2
</version>
<!--$NO-MVN-MAN-VER$-->
<executions>
<executions>
<execution>
<execution>
<phase>
package
</phase>
<phase>
package
</phase>
<goals>
<goals>
<goal>
java
</goal>
<goal>
java
</goal>
</goals>
</goals>
</execution>
</execution>
</executions>
</executions>
<configuration>
<configuration>
<!--
<mainClass>Aberration_Calibration</mainClass> -->
<!-- <mainClass>Aberration_Calibration</mainClass> -->
<mainClass>
Eyesis_Correction
</mainClass>
<mainClass>
Eyesis_Correction
</mainClass>
</configuration>
</configuration>
</plugin>
</plugin>
...
@@ -253,11 +252,35 @@
...
@@ -253,11 +252,35 @@
<format>
Build {0,date,yyyy-MM-dd} {0,time,HH:MM:SS} on host {1}
</format>
<format>
Build {0,date,yyyy-MM-dd} {0,time,HH:MM:SS} on host {1}
</format>
<items>
<items>
<item>
timestamp
</item>
<item>
timestamp
</item>
<!-- <item>foxel-MRHM7AP</item> -->
</items>
</items>
</configuration>
</configuration>
</plugin>
</plugin>
<!-- Trying sources/javadocs -->
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-dependency-plugin
</artifactId>
<version>
3.1.2
</version>
<executions>
<execution>
<goals>
<goal>
sources
</goal>
<goal>
resolve
</goal>
</goals>
<configuration>
<classifier>
javadoc
</classifier>
</configuration>
</execution>
</executions>
</plugin>
<!-- End of Trying sources/javadocs -->
</plugins>
</plugins>
</pluginManagement>
</pluginManagement>
</build>
</build>
...
...
src/main/java/com/elphel/imagej/correction/EyesisCorrections.java
View file @
6894dccd
...
@@ -2741,7 +2741,7 @@ public class EyesisCorrections {
...
@@ -2741,7 +2741,7 @@ public class EyesisCorrections {
}
else
{
}
else
{
if
(
debugLevel
>
0
)
System
.
out
.
println
(
"Saving RGBA result to "
+
path
+
".tiff"
);
if
(
debugLevel
>
0
)
System
.
out
.
println
(
"Saving RGBA result to "
+
path
+
".tiff"
);
try
{
try
{
(
new
EyesisTiff
())
.
saveTiffARGB32
(
EyesisTiff
.
saveTiffARGB32
(
imp
,
imp
,
path
+
".tiff"
,
//path, // +".tiff",
path
+
".tiff"
,
//path, // +".tiff",
false
,
// correctionsParameters.imageJTags,
false
,
// correctionsParameters.imageJTags,
...
@@ -2777,7 +2777,7 @@ public class EyesisCorrections {
...
@@ -2777,7 +2777,7 @@ public class EyesisCorrections {
if
((
imp
.
getStackSize
()
==
4
)
&&
imp
.
getStack
().
getSliceLabel
(
4
).
equals
(
"alpha"
)){
if
((
imp
.
getStackSize
()
==
4
)
&&
imp
.
getStack
().
getSliceLabel
(
4
).
equals
(
"alpha"
)){
try
{
try
{
(
new
EyesisTiff
())
.
saveTiff
(
EyesisTiff
.
saveTiff
(
imp
,
imp
,
path
+
".tiff"
,
path
+
".tiff"
,
mode
,
//
mode
,
//
...
...
src/main/java/com/elphel/imagej/correction/Eyesis_Correction.java
View file @
6894dccd
...
@@ -43,6 +43,7 @@ import java.awt.event.ActionListener;
...
@@ -43,6 +43,7 @@ import java.awt.event.ActionListener;
import
java.awt.event.MouseAdapter
;
import
java.awt.event.MouseAdapter
;
import
java.awt.event.MouseEvent
;
import
java.awt.event.MouseEvent
;
import
java.awt.event.WindowEvent
;
import
java.awt.event.WindowEvent
;
import
java.awt.image.BufferedImage
;
import
java.io.File
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileInputStream
;
import
java.io.FileNotFoundException
;
import
java.io.FileNotFoundException
;
...
@@ -70,9 +71,22 @@ import java.util.Properties;
...
@@ -70,9 +71,22 @@ import java.util.Properties;
import
java.util.Set
;
import
java.util.Set
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
javax.imageio.ImageIO
;
import
javax.imageio.ImageTypeSpecifier
;
import
javax.imageio.ImageWriteParam
;
import
javax.imageio.ImageWriter
;
import
javax.imageio.metadata.IIOInvalidTreeException
;
import
javax.imageio.metadata.IIOMetadata
;
import
javax.imageio.metadata.IIOMetadataFormatImpl
;
import
javax.imageio.metadata.IIOMetadataNode
;
import
javax.imageio.plugins.tiff.ExifGPSTagSet
;
import
javax.imageio.plugins.tiff.TIFFDirectory
;
import
javax.imageio.plugins.tiff.TIFFTagSet
;
import
javax.swing.JFileChooser
;
import
javax.swing.JFileChooser
;
import
javax.swing.filechooser.FileFilter
;
import
javax.swing.filechooser.FileFilter
;
import
org.w3c.dom.Node
;
import
com.elphel.imagej.calibration.CalibrationFileManagement
;
import
com.elphel.imagej.calibration.CalibrationFileManagement
;
import
com.elphel.imagej.calibration.CalibrationIllustration
;
import
com.elphel.imagej.calibration.CalibrationIllustration
;
import
com.elphel.imagej.calibration.CalibrationIllustrationParameters
;
import
com.elphel.imagej.calibration.CalibrationIllustrationParameters
;
...
@@ -95,6 +109,8 @@ import com.elphel.imagej.ims.EventLogger;
...
@@ -95,6 +109,8 @@ import com.elphel.imagej.ims.EventLogger;
import
com.elphel.imagej.ims.Imx5
;
import
com.elphel.imagej.ims.Imx5
;
import
com.elphel.imagej.jp4.JP46_Reader_camera
;
import
com.elphel.imagej.jp4.JP46_Reader_camera
;
import
com.elphel.imagej.lwir.LwirReader
;
import
com.elphel.imagej.lwir.LwirReader
;
import
com.elphel.imagej.readers.ChangeImageResolution
;
import
com.elphel.imagej.readers.DumpImageMetadata
;
import
com.elphel.imagej.readers.EyesisTiff
;
import
com.elphel.imagej.readers.EyesisTiff
;
import
com.elphel.imagej.tensorflow.TensorflowInferModel
;
import
com.elphel.imagej.tensorflow.TensorflowInferModel
;
import
com.elphel.imagej.tileprocessor.Clt1d
;
import
com.elphel.imagej.tileprocessor.Clt1d
;
...
@@ -578,6 +594,7 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
...
@@ -578,6 +594,7 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
if
(
ADVANCED_MODE
)
{
if
(
ADVANCED_MODE
)
{
addButton
(
"Tiff Writer"
,
panel7
);
addButton
(
"Tiff Writer"
,
panel7
);
addButton
(
"Tiff Properties"
,
panel7
);
addButton
(
"Tiff Properties"
,
panel7
);
addButton
(
"Add TIFF resolution"
,
panel7
);
}
}
plugInFrame
.
add
(
panel7
);
plugInFrame
.
add
(
panel7
);
...
@@ -1662,7 +1679,7 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
...
@@ -1662,7 +1679,7 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
/* ======================================================================== */
/* ======================================================================== */
}
else
if
(
label
.
equals
(
"Tiff Writer"
))
{
}
else
if
(
label
.
equals
(
"Tiff Writer"
))
{
DEBUG_LEVEL
=
MASTER_DEBUG_LEVEL
;
DEBUG_LEVEL
=
MASTER_DEBUG_LEVEL
;
EyesisTiff
eyesisTiff
=
new
EyesisTiff
();
//
EyesisTiff eyesisTiff = new EyesisTiff();
ImagePlus
imp_sel
=
WindowManager
.
getCurrentImage
();
ImagePlus
imp_sel
=
WindowManager
.
getCurrentImage
();
if
(
imp_sel
==
null
)
{
if
(
imp_sel
==
null
)
{
IJ
.
showMessage
(
"Error"
,
"No images selected"
);
IJ
.
showMessage
(
"Error"
,
"No images selected"
);
...
@@ -1676,7 +1693,7 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
...
@@ -1676,7 +1693,7 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
}
}
try
{
try
{
try
{
try
{
e
yesisTiff
.
saveTiff
(
imp_sel
,
path
,
CORRECTION_PARAMETERS
.
equirectangularFormat
,
E
yesisTiff
.
saveTiff
(
imp_sel
,
path
,
CORRECTION_PARAMETERS
.
equirectangularFormat
,
(
CORRECTION_PARAMETERS
.
equirectangularFormat
==
3
)
?
CORRECTION_PARAMETERS
.
outputRangeFP
(
CORRECTION_PARAMETERS
.
equirectangularFormat
==
3
)
?
CORRECTION_PARAMETERS
.
outputRangeFP
:
CORRECTION_PARAMETERS
.
outputRangeInt
,
:
CORRECTION_PARAMETERS
.
outputRangeInt
,
CORRECTION_PARAMETERS
.
imageJTags
,
DEBUG_LEVEL
);
CORRECTION_PARAMETERS
.
imageJTags
,
DEBUG_LEVEL
);
...
@@ -1696,13 +1713,109 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
...
@@ -1696,13 +1713,109 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
/* ======================================================================== */
/* ======================================================================== */
}
else
if
(
label
.
equals
(
"Tiff Properties"
))
{
}
else
if
(
label
.
equals
(
"Tiff Properties"
))
{
DEBUG_LEVEL
=
MASTER_DEBUG_LEVEL
;
DEBUG_LEVEL
=
MASTER_DEBUG_LEVEL
;
EyesisTiff
eyesisTiff
=
new
EyesisTiff
();
ImagePlus
imp_sel
=
WindowManager
.
getCurrentImage
();
ImagePlus
imp_sel
=
WindowManager
.
getCurrentImage
();
if
(
imp_sel
==
null
)
{
if
(
imp_sel
==
null
)
{
IJ
.
showMessage
(
"Error"
,
"No images selected"
);
IJ
.
showMessage
(
"Error"
,
"No images selected"
);
return
;
return
;
}
}
eyesisTiff
.
propertiesTiff
(
imp_sel
);
String
orig_path
=
imp_sel
.
getOriginalFileInfo
().
getFilePath
();
try
{
DumpImageMetadata
.
processFile
(
new
File
(
orig_path
));
}
catch
(
IOException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
// EyesisTiff.propertiesTiff(imp_sel);
return
;
/* ======================================================================== */
}
else
if
(
label
.
equals
(
"Add TIFF resolution"
))
{
DEBUG_LEVEL
=
MASTER_DEBUG_LEVEL
;
ImagePlus
imp_sel
=
WindowManager
.
getCurrentImage
();
if
(
imp_sel
==
null
)
{
IJ
.
showMessage
(
"Error"
,
"No images selected"
);
return
;
}
String
orig_path
=
imp_sel
.
getOriginalFileInfo
().
getFilePath
();
// Testing change image resolution
File
inputFile
=
new
File
(
orig_path
);
IIOMetadata
inMetadata
=
null
;
try
{
inMetadata
=
DumpImageMetadata
.
getFileMetadata
(
inputFile
);
}
catch
(
IOException
e1
)
{
// TODO Auto-generated catch block
e1
.
printStackTrace
();
return
;
}
double
resolutionDPI
=
600
;
File
outputFile
=
new
File
(
orig_path
+
"_"
+((
int
)
resolutionDPI
)+
"-01.tiff"
);
BufferedImage
image
=
null
;
try
{
image
=
ChangeImageResolution
.
readImage
(
inputFile
);
// wrong imageType 0 (should be 2)
}
catch
(
IOException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
return
;
}
IIOMetadataNode
newMetadata
=
ChangeImageResolution
.
createResolutionMetadata
(
resolutionDPI
);
// IIOMetadataNode addMetadata = ChangeImageResolution.createResolutionMetadata0(resolutionDPI);
// inMetaData.appendChild()
try
{
inMetadata
.
mergeTree
(
IIOMetadataFormatImpl
.
standardMetadataFormatName
,
newMetadata
);
}
catch
(
IIOInvalidTreeException
e1
)
{
// TODO Auto-generated catch block
e1
.
printStackTrace
();
return
;
}
Node
metadata_as_tree
=
inMetadata
.
getAsTree
(
"javax_imageio_tiff_image_1.0"
);
BufferedImage
bufferedImageAlpha
=
new
BufferedImage
(
image
.
getWidth
(),
image
.
getHeight
(),
BufferedImage
.
TYPE_INT_ARGB
);
ImageWriter
tiffWriter
=
ImageIO
.
getImageWritersByFormatName
(
"tiff"
).
next
();
ImageWriteParam
tiffWriteParam
=
tiffWriter
.
getDefaultWriteParam
();
tiffWriteParam
.
setCompressionMode
(
ImageWriteParam
.
MODE_DISABLED
);
ImageTypeSpecifier
imageType
=
ImageTypeSpecifier
.
createFromRenderedImage
(
bufferedImageAlpha
);
IIOMetadata
imageMetadata
=
tiffWriter
.
getDefaultImageMetadata
(
imageType
,
tiffWriteParam
);
TIFFDirectory
directory
=
null
;
try
{
directory
=
TIFFDirectory
.
createFromMetadata
(
imageMetadata
);
}
catch
(
IIOInvalidTreeException
e2
)
{
// TODO Auto-generated catch block
e2
.
printStackTrace
();
}
/// TIFFTagSet tag_set = ExifGPSTagSet.getInstance();
/// directory.addTagSet(tag_set); // ExifGPSTagSet.getInstance());
//// imageMetadata = directory.getAsMetadata();
System
.
out
.
println
(
"\n=== metadata_as_tree ===:"
);
DumpImageMetadata
.
displayMetadataNode
(
metadata_as_tree
,
1
);
System
.
out
.
println
(
"\n=== imageMetadata as javax_imageio_tiff_image_1.0 ===:"
);
DumpImageMetadata
.
displayMetadataNode
(
imageMetadata
.
getAsTree
(
"javax_imageio_tiff_image_1.0"
),
1
);
try
{
// imageMetadata.mergeTree(IIOMetadataFormatImpl.standardMetadataFormatName, metadata_as_tree);
imageMetadata
.
mergeTree
(
"javax_imageio_tiff_image_1.0"
,
metadata_as_tree
);
}
catch
(
IIOInvalidTreeException
e1
)
{
// TODO Auto-generated catch block
e1
.
printStackTrace
();
return
;
}
System
.
out
.
println
(
"\n=== imageMetadata merged as javax_imageio_tiff_image_1.0 ===:"
);
DumpImageMetadata
.
displayMetadataNode
(
imageMetadata
.
getAsTree
(
"javax_imageio_tiff_image_1.0"
),
1
);
// works with inMetadata. Will it with imageMetadata?
try
{
ChangeImageResolution
.
writeImage
(
outputFile
,
image
,
imageMetadata
);
// inMetadata); // newMetadata);
}
catch
(
IOException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
return
;
return
;
/* ======================================================================== */
/* ======================================================================== */
}
else
if
(
label
.
equals
(
"Configure PP"
))
{
}
else
if
(
label
.
equals
(
"Configure PP"
))
{
...
...
src/main/java/com/elphel/imagej/ims/Did_ins.java
View file @
6894dccd
package
com
.
elphel
.
imagej
.
ims
;
package
com
.
elphel
.
imagej
.
ims
;
import
java.time.LocalDate
;
import
java.time.LocalDateTime
;
import
java.util.Properties
;
import
java.util.Properties
;
import
com.elphel.imagej.tileprocessor.IntersceneMatchParameters
;
import
com.elphel.imagej.tileprocessor.IntersceneMatchParameters
;
public
abstract
class
Did_ins
<
T
extends
Did_ins
<
T
>>{
public
abstract
class
Did_ins
<
T
extends
Did_ins
<
T
>>{
final
static
LocalDateTime
DT_01_06_1980
=
LocalDateTime
.
of
(
1980
,
1
,
6
,
0
,
0
);
final
static
int
WEEK_SECONDS
=
7
*
24
*
3600
;
final
static
int
WEEK_SECONDS
=
7
*
24
*
3600
;
/** GPS number of weeks since January 6th, 1980 */
/** GPS number of weeks since January 6th, 1980 */
public
int
week
;
// uint32_t
public
int
week
;
// uint32_t
...
@@ -49,6 +52,20 @@ public abstract class Did_ins <T extends Did_ins <T>>{
...
@@ -49,6 +52,20 @@ public abstract class Did_ins <T extends Did_ins <T>>{
return
new
int
[]
{
week
,
(
int
)
Math
.
round
(
timeOfWeek
*
1000.0
)};
return
new
int
[]
{
week
,
(
int
)
Math
.
round
(
timeOfWeek
*
1000.0
)};
}
}
public
static
LocalDateTime
getLocalDateTime
(
int
week
,
double
tow
)
{
/** GPS number of weeks since January 6th, 1980 */
/** GPS time of week (since Sunday morning) in seconds */
int
seconds
=
(
int
)
Math
.
floor
(
tow
);
int
nanos
=
(
int
)
Math
.
floor
((
tow
-
seconds
)*
1
E9
);
return
DT_01_06_1980
.
plusWeeks
(
week
).
plusSeconds
(
seconds
).
plusNanos
(
nanos
);
}
public
LocalDateTime
getLocalDateTime
()
{
return
getLocalDateTime
(
week
,
timeOfWeek
);
}
public
boolean
isDidSane
()
{
public
boolean
isDidSane
()
{
if
((
week
<
MIN_WEEK
)
||
(
week
>
MAX_WEEK
))
{
if
((
week
<
MIN_WEEK
)
||
(
week
>
MAX_WEEK
))
{
System
.
out
.
println
(
"isDidSane(): bad week = "
+
week
+
System
.
out
.
println
(
"isDidSane(): bad week = "
+
week
+
...
...
src/main/java/com/elphel/imagej/readers/ChangeImageResolution.java
0 → 100644
View file @
6894dccd
package
com
.
elphel
.
imagej
.
readers
;
//https://www.silverbaytech.com/2014/06/04/iiometadata-tutorial-part-3-writing-metadata/
/*
* Copyright (c) 2014 Kevin Hunter
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
//package com.silverbaytech.blog.imageIoMetadata;
import
java.awt.image.BufferedImage
;
import
java.io.File
;
import
java.io.IOException
;
import
java.util.Iterator
;
import
javax.imageio.IIOImage
;
import
javax.imageio.ImageIO
;
import
javax.imageio.ImageReader
;
import
javax.imageio.ImageTypeSpecifier
;
import
javax.imageio.ImageWriteParam
;
import
javax.imageio.ImageWriter
;
import
javax.imageio.metadata.IIOMetadata
;
import
javax.imageio.metadata.IIOMetadataFormatImpl
;
import
javax.imageio.metadata.IIOMetadataNode
;
import
javax.imageio.stream.ImageInputStream
;
import
javax.imageio.stream.ImageOutputStream
;
public
class
ChangeImageResolution
{
private
static
String
getFileExtension
(
File
file
)
{
String
fileName
=
file
.
getName
();
int
lastDot
=
fileName
.
lastIndexOf
(
'.'
);
return
fileName
.
substring
(
lastDot
+
1
);
}
public
static
BufferedImage
readImage
(
File
file
)
throws
IOException
{
ImageInputStream
stream
=
null
;
BufferedImage
image
=
null
;
try
{
stream
=
ImageIO
.
createImageInputStream
(
file
);
Iterator
<
ImageReader
>
readers
=
ImageIO
.
getImageReaders
(
stream
);
if
(
readers
.
hasNext
())
{
ImageReader
reader
=
readers
.
next
();
reader
.
setInput
(
stream
);
image
=
reader
.
read
(
0
);
}
}
finally
{
if
(
stream
!=
null
)
{
stream
.
close
();
}
}
return
image
;
}
//https://docs.oracle.com/en/java/javase/17/docs/api/java.desktop/javax/imageio/metadata/doc-files/standard_metadata.html
public
static
IIOMetadataNode
createResolutionMetadata
(
double
resolutionDPI
)
{
String
pixelSize
=
Double
.
toString
(
25.4
/
resolutionDPI
);
IIOMetadataNode
horizontal
=
new
IIOMetadataNode
(
"HorizontalPixelSize"
);
horizontal
.
setAttribute
(
"value"
,
pixelSize
);
IIOMetadataNode
vertical
=
new
IIOMetadataNode
(
"VerticalPixelSize"
);
vertical
.
setAttribute
(
"value"
,
pixelSize
);
IIOMetadataNode
dimension
=
new
IIOMetadataNode
(
"Dimension"
);
dimension
.
appendChild
(
horizontal
);
dimension
.
appendChild
(
vertical
);
IIOMetadataNode
root
=
new
IIOMetadataNode
(
IIOMetadataFormatImpl
.
standardMetadataFormatName
);
root
.
appendChild
(
dimension
);
return
root
;
}
public
static
IIOMetadataNode
createResolutionMetadata0
(
double
resolutionDPI
)
{
String
pixelSize
=
Double
.
toString
(
25.4
/
resolutionDPI
);
IIOMetadataNode
horizontal
=
new
IIOMetadataNode
(
"HorizontalPixelSize"
);
horizontal
.
setAttribute
(
"value"
,
pixelSize
);
IIOMetadataNode
vertical
=
new
IIOMetadataNode
(
"VerticalPixelSize"
);
vertical
.
setAttribute
(
"value"
,
pixelSize
);
IIOMetadataNode
dimension
=
new
IIOMetadataNode
(
"Dimension"
);
dimension
.
appendChild
(
horizontal
);
dimension
.
appendChild
(
vertical
);
return
dimension
;
// IIOMetadataNode root = new IIOMetadataNode(IIOMetadataFormatImpl.standardMetadataFormatName);
// root.appendChild(dimension);
// return root;
}
public
static
void
writeImage
(
File
outputFile
,
BufferedImage
image
,
IIOMetadataNode
newMetadata
)
throws
IOException
{
String
extension
=
getFileExtension
(
outputFile
);
ImageTypeSpecifier
imageType
=
ImageTypeSpecifier
.
createFromBufferedImageType
(
image
.
getType
());
ImageOutputStream
stream
=
null
;
try
{
Iterator
<
ImageWriter
>
writers
=
ImageIO
.
getImageWritersBySuffix
(
extension
);
while
(
writers
.
hasNext
())
{
ImageWriter
writer
=
writers
.
next
();
ImageWriteParam
writeParam
=
writer
.
getDefaultWriteParam
();
IIOMetadata
imageMetadata
=
writer
.
getDefaultImageMetadata
(
imageType
,
writeParam
);
if
(!
imageMetadata
.
isStandardMetadataFormatSupported
())
{
continue
;
}
if
(
imageMetadata
.
isReadOnly
())
{
continue
;
}
imageMetadata
.
mergeTree
(
IIOMetadataFormatImpl
.
standardMetadataFormatName
,
newMetadata
);
IIOImage
imageWithMetadata
=
new
IIOImage
(
image
,
null
,
imageMetadata
);
stream
=
ImageIO
.
createImageOutputStream
(
outputFile
);
writer
.
setOutput
(
stream
);
writer
.
write
(
null
,
imageWithMetadata
,
writeParam
);
}
}
finally
{
if
(
stream
!=
null
)
{
stream
.
close
();
}
}
}
public
static
void
writeImage
(
File
outputFile
,
BufferedImage
image
,
IIOMetadata
newMetadata
)
throws
IOException
{
String
extension
=
getFileExtension
(
outputFile
);
ImageTypeSpecifier
imageType
=
ImageTypeSpecifier
.
createFromBufferedImageType
(
image
.
getType
());
ImageOutputStream
stream
=
null
;
try
{
Iterator
<
ImageWriter
>
writers
=
ImageIO
.
getImageWritersBySuffix
(
extension
);
while
(
writers
.
hasNext
())
{
ImageWriter
writer
=
writers
.
next
();
ImageWriteParam
writeParam
=
writer
.
getDefaultWriteParam
();
/*
IIOMetadata imageMetadata = writer.getDefaultImageMetadata(imageType, writeParam);
if (!imageMetadata.isStandardMetadataFormatSupported())
{
continue;
}
if (imageMetadata.isReadOnly())
{
continue;
}
imageMetadata.mergeTree(IIOMetadataFormatImpl.standardMetadataFormatName, newMetadata);
*/
IIOImage
imageWithMetadata
=
new
IIOImage
(
image
,
null
,
newMetadata
);
stream
=
ImageIO
.
createImageOutputStream
(
outputFile
);
writer
.
setOutput
(
stream
);
writer
.
write
(
null
,
imageWithMetadata
,
writeParam
);
}
}
finally
{
if
(
stream
!=
null
)
{
stream
.
close
();
}
}
}
public
static
void
main
(
String
[]
args
)
{
if
(
args
.
length
!=
3
)
{
System
.
out
.
println
(
"Usage: ChangeImageResolution inputFile newResolutionDPI outputFile"
);
return
;
}
try
{
File
inputFile
=
new
File
(
args
[
0
]);
double
resolutionDPI
=
Double
.
parseDouble
(
args
[
1
]);
File
outputFile
=
new
File
(
args
[
2
]);
BufferedImage
image
=
readImage
(
inputFile
);
IIOMetadataNode
newMetadata
=
createResolutionMetadata
(
resolutionDPI
);
writeImage
(
outputFile
,
image
,
newMetadata
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
}
src/main/java/com/elphel/imagej/readers/DumpImageMetadata.java
0 → 100644
View file @
6894dccd
/*
https://www.silverbaytech.com/2014/05/29/iiometadata-tutorial-part-2-retrieving-image-metadata/
*/
package
com
.
elphel
.
imagej
.
readers
;
/*
* Copyright (c) 2014 Kevin Hunter
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
//package com.silverbaytech.blog.imageIoMetadata;
import
java.io.File
;
import
java.io.IOException
;
import
java.util.Iterator
;
import
javax.imageio.ImageIO
;
import
javax.imageio.ImageReader
;
import
javax.imageio.metadata.IIOMetadata
;
import
javax.imageio.stream.ImageInputStream
;
import
org.w3c.dom.NamedNodeMap
;
import
org.w3c.dom.Node
;
/**
* Dump the ImageIO metadata associated with one or more images.
*
* @author Kevin Hunter
*
*/
public
class
DumpImageMetadata
{
private
static
String
getFileExtension
(
File
file
)
{
String
fileName
=
file
.
getName
();
int
lastDot
=
fileName
.
lastIndexOf
(
'.'
);
return
fileName
.
substring
(
lastDot
+
1
);
}
private
static
void
indent
(
int
level
)
{
for
(
int
i
=
0
;
i
<
level
;
i
++)
{
System
.
out
.
print
(
" "
);
}
}
private
static
void
displayAttributes
(
NamedNodeMap
attributes
)
{
if
(
attributes
!=
null
)
{
int
count
=
attributes
.
getLength
();
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
Node
attribute
=
attributes
.
item
(
i
);
System
.
out
.
print
(
" "
);
System
.
out
.
print
(
attribute
.
getNodeName
());
System
.
out
.
print
(
"='"
);
System
.
out
.
print
(
attribute
.
getNodeValue
());
System
.
out
.
print
(
"'"
);
}
}
}
public
static
void
displayMetadataNode
(
Node
node
,
int
level
)
{
indent
(
level
);
System
.
out
.
print
(
"<"
);
System
.
out
.
print
(
node
.
getNodeName
());
NamedNodeMap
attributes
=
node
.
getAttributes
();
displayAttributes
(
attributes
);
Node
child
=
node
.
getFirstChild
();
if
(
child
==
null
)
{
String
value
=
node
.
getNodeValue
();
if
(
value
==
null
||
value
.
length
()
==
0
)
{
System
.
out
.
println
(
"/>"
);
}
else
{
System
.
out
.
print
(
">"
);
System
.
out
.
print
(
value
);
System
.
out
.
print
(
"<"
);
System
.
out
.
print
(
node
.
getNodeName
());
System
.
out
.
println
(
">"
);
}
return
;
}
System
.
out
.
println
(
">"
);
while
(
child
!=
null
)
{
displayMetadataNode
(
child
,
level
+
1
);
child
=
child
.
getNextSibling
();
}
indent
(
level
);
System
.
out
.
print
(
"</"
);
System
.
out
.
print
(
node
.
getNodeName
());
System
.
out
.
println
(
">"
);
}
private
static
void
dumpMetadata
(
IIOMetadata
metadata
)
{
String
[]
names
=
metadata
.
getMetadataFormatNames
();
int
length
=
names
.
length
;
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
indent
(
2
);
System
.
out
.
println
(
"Format name: "
+
names
[
i
]);
displayMetadataNode
(
metadata
.
getAsTree
(
names
[
i
]),
3
);
}
}
private
static
void
processFileWithReader
(
File
file
,
ImageReader
reader
)
throws
IOException
{
ImageInputStream
stream
=
null
;
try
{
stream
=
ImageIO
.
createImageInputStream
(
file
);
reader
.
setInput
(
stream
,
true
);
IIOMetadata
metadata
=
reader
.
getImageMetadata
(
0
);
indent
(
1
);
System
.
out
.
println
(
"Image metadata"
);
dumpMetadata
(
metadata
);
IIOMetadata
smetadata
=
reader
.
getStreamMetadata
();
if
(
smetadata
!=
null
)
{
indent
(
1
);
System
.
out
.
println
(
"Stream metadata"
);
dumpMetadata
(
smetadata
);
}
}
finally
{
if
(
stream
!=
null
)
{
stream
.
close
();
}
}
}
public
static
void
processFile
(
File
file
)
throws
IOException
{
System
.
out
.
println
(
"\nProcessing "
+
file
.
getName
()
+
":\n"
);
String
extension
=
getFileExtension
(
file
);
Iterator
<
ImageReader
>
readers
=
ImageIO
.
getImageReadersByFormatName
(
extension
);
while
(
readers
.
hasNext
())
{
ImageReader
reader
=
readers
.
next
();
System
.
out
.
println
(
"Reader: "
+
reader
.
getClass
().
getName
());
processFileWithReader
(
file
,
reader
);
}
}
public
static
IIOMetadata
getFileMetadata
(
File
file
)
throws
IOException
{
String
extension
=
getFileExtension
(
file
);
Iterator
<
ImageReader
>
readers
=
ImageIO
.
getImageReadersByFormatName
(
extension
);
IIOMetadata
metadata
=
null
;
if
(
readers
.
hasNext
())
{
ImageReader
reader
=
readers
.
next
();
System
.
out
.
println
(
"Reader: "
+
reader
.
getClass
().
getName
());
// processFileWithReader(file, reader);
ImageInputStream
stream
=
null
;
try
{
stream
=
ImageIO
.
createImageInputStream
(
file
);
reader
.
setInput
(
stream
,
true
);
metadata
=
reader
.
getImageMetadata
(
0
);
}
finally
{
if
(
stream
!=
null
)
{
stream
.
close
();
}
}
}
return
metadata
;
}
public
static
void
processDirectory
(
File
directory
)
throws
IOException
{
System
.
out
.
println
(
"Processing all files in "
+
directory
.
getAbsolutePath
());
File
[]
contents
=
directory
.
listFiles
();
for
(
File
file
:
contents
)
{
if
(
file
.
isFile
())
{
processFile
(
file
);
}
}
}
public
static
void
main
(
String
[]
args
)
{
try
{
for
(
int
i
=
0
;
i
<
args
.
length
;
i
++)
{
File
fileOrDirectory
=
new
File
(
args
[
i
]);
if
(
fileOrDirectory
.
isFile
())
{
processFile
(
fileOrDirectory
);
}
else
{
processDirectory
(
fileOrDirectory
);
}
}
System
.
out
.
println
(
"\nDone"
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
\ No newline at end of file
src/main/java/com/elphel/imagej/readers/ElphelTiffReader.java
View file @
6894dccd
...
@@ -59,9 +59,6 @@ import loci.formats.FormatTools;
...
@@ -59,9 +59,6 @@ import loci.formats.FormatTools;
import
loci.formats.in.MetadataLevel
;
import
loci.formats.in.MetadataLevel
;
import
loci.formats.in.TiffReader
;
import
loci.formats.in.TiffReader
;
import
loci.formats.meta.MetadataStore
;
import
loci.formats.meta.MetadataStore
;
import
loci.formats.tiff.IFD
;
import
loci.formats.tiff.IFDList
;
import
loci.formats.tiff.TiffRational
;
import
ome.xml.model.primitives.Timestamp
;
import
ome.xml.model.primitives.Timestamp
;
/*
/*
...
...
src/main/java/com/elphel/imagej/readers/ElphelTiffWriter.java
0 → 100644
View file @
6894dccd
This diff is collapsed.
Click to expand it.
src/main/java/com/elphel/imagej/readers/EyesisTiff.java
View file @
6894dccd
...
@@ -57,6 +57,9 @@ import org.w3c.dom.NodeList;
...
@@ -57,6 +57,9 @@ import org.w3c.dom.NodeList;
import
org.xml.sax.InputSource
;
import
org.xml.sax.InputSource
;
import
org.xml.sax.SAXException
;
import
org.xml.sax.SAXException
;
import
com.elphel.imagej.correction.Eyesis_Correction
;
import
com.elphel.imagej.tileprocessor.QuadCLTCPU
;
//import org.apache.log4j.Logger;
//import org.apache.log4j.Logger;
import
ij.IJ
;
import
ij.IJ
;
...
@@ -305,13 +308,42 @@ the type of pixel data in this file getPixelType()
...
@@ -305,13 +308,42 @@ the type of pixel data in this file getPixelType()
)
throws
IOException
,
FormatException
,
ServiceException
,
DependencyException
{
)
throws
IOException
,
FormatException
,
ServiceException
,
DependencyException
{
if
(
imp
.
getType
()==
ImagePlus
.
COLOR_RGB
)
{
// 4*8 bit - type = 0
if
(
imp
.
getType
()==
ImagePlus
.
COLOR_RGB
)
{
// 4*8 bit - type = 0
if
(
debugLevel
>
1
)
System
.
out
.
println
(
"Saving 8-bit TIFF with alpha-channel: "
+
path
);
// is it possible to just add alpha to high bytes?
if
(
debugLevel
>
1
)
System
.
out
.
println
(
"Saving 8-bit TIFF with alpha-channel: "
+
path
);
// is it possible to just add alpha to high bytes?
saveTiffARGB32
(
imp
,
path
,
imageJTags
,
debugLevel
);
ElphelTiffWriter
.
saveTiffARGB32
(
imp
,
path
,
imageJTags
,
debugLevel
);
// saveTiffARGB32(imp, path, imageJTags, debugLevel);
return
;
return
;
}
else
if
(
imp
.
getStackSize
()==
4
)
{
}
else
if
(
imp
.
getStackSize
()==
4
)
{
if
(
debugLevel
>
1
)
System
.
out
.
println
(
"Saving 32-bit float TIFF with alpha-channel: "
+
path
);
if
(
debugLevel
>
1
)
System
.
out
.
println
(
"Saving 32-bit float TIFF with alpha-channel: "
+
path
);
saveTiffARGB
(
imp
,
path
,
mode
,
scale
,
imageJTags
,
debugLevel
);
saveTiffARGB
(
imp
,
path
,
mode
,
scale
,
imageJTags
,
debugLevel
);
return
;
return
;
}
else
if
(
imp
.
getType
()==
ImagePlus
.
GRAY32
)
{
int
lwir_palette
=
0
;
double
[]
minmax
=
null
;
String
title
=
imp
.
getTitle
();
float
[]
fpixels
=
(
float
[])
imp
.
getProcessor
().
getPixels
();
double
[]
dpixels
=
new
double
[
fpixels
.
length
];
for
(
int
i
=
0
;
i
<
fpixels
.
length
;
i
++)
{
dpixels
[
i
]
=
fpixels
[
i
];
}
ImagePlus
imp_rgb
=
QuadCLTCPU
.
linearStackToColorLWIR
(
Eyesis_Correction
.
CLT_PARAMETERS
,
// clt_parameters, // CLTParameters clt_parameters,
lwir_palette
,
// int lwir_palette, // <0 - do not convert
minmax
,
// minmax, // double [] minmax,
title
,
// String name,
"-rgba"
,
// String suffix, // such as disparity=...
true
,
// boolean toRGB,
new
double
[][]
{
dpixels
},
// faded_textures[nslice], // double [][] texture_data,
imp
.
getWidth
(),
// int width, // int tilesX,
imp
.
getHeight
(),
// int height, // int tilesY,
debugLevel
);
// int debugLevel )
// File test_dump = new File("/home/elphel/Documents/DoD/Ukraine/photos/test/1694531940_120446-02-gps.tiff");
// DumpImageMetadata.processFile(test_dump);
if
(
debugLevel
>
1
)
System
.
out
.
println
(
"Saving 8-bit RGBA TIFF with alpha-channel: "
+
path
);
// is it possible to just add alpha to high bytes?
ElphelTiffWriter
.
saveTiffARGB32
(
imp_rgb
,
path
,
imageJTags
,
debugLevel
);
// saveTiffARGB32(imp_rgb, path, imageJTags, debugLevel);
return
;
}
}
IJ
.
showMessage
(
"Not yet implemented for this image type"
);
IJ
.
showMessage
(
"Not yet implemented for this image type"
);
}
}
...
@@ -523,8 +555,8 @@ the type of pixel data in this file getPixelType()
...
@@ -523,8 +555,8 @@ the type of pixel data in this file getPixelType()
// copy some other data?
// copy some other data?
ifd
.
putIFDValue
(
IFD
.
COMPRESSION
,
1
);
//TiffCompression.UNCOMPRESSED);
ifd
.
putIFDValue
(
IFD
.
COMPRESSION
,
1
);
//TiffCompression.UNCOMPRESSED);
ifd
.
putIFDValue
(
IFD
.
PHOTOMETRIC_INTERPRETATION
,
2
);
// RGB
ifd
.
putIFDValue
(
IFD
.
PHOTOMETRIC_INTERPRETATION
,
2
);
// RGB
// ifd.putIFDValue(IFD.EXTRA_SAMPLES,2); // extra
bytes (over 3) meaning Unassociated alpha data
ifd
.
putIFDValue
(
IFD
.
EXTRA_SAMPLES
,
2
);
// extra 2
bytes (over 3) meaning Unassociated alpha data
ifd
.
putIFDValue
(
IFD
.
EXTRA_SAMPLES
,
1
);
// extra bytes (over 3) meaning Una
ssociated alpha data
// ifd.putIFDValue(IFD.EXTRA_SAMPLES,1); // extra 1 byte (over 3) meaning A
ssociated alpha data
ifd
.
putIFDValue
(
IFD
.
SAMPLE_FORMAT
,
1
);
//
ifd
.
putIFDValue
(
IFD
.
SAMPLE_FORMAT
,
1
);
//
// int [] bpsArray={8,8,8,8};
// int [] bpsArray={8,8,8,8};
// ifd.putIFDValue(IFD.BITS_PER_SAMPLE, bpsArray); // will be done automatically
// ifd.putIFDValue(IFD.BITS_PER_SAMPLE, bpsArray); // will be done automatically
...
@@ -571,7 +603,6 @@ the type of pixel data in this file getPixelType()
...
@@ -571,7 +603,6 @@ the type of pixel data in this file getPixelType()
public
static
void
propertiesTiff
(
ImagePlus
imp
){
public
static
void
propertiesTiff
(
ImagePlus
imp
){
FileInfo
fi
=
imp
.
getOriginalFileInfo
();
FileInfo
fi
=
imp
.
getOriginalFileInfo
();
if
((
fi
==
null
)
||(
fi
.
directory
==
null
)
||
(
fi
.
fileFormat
!=
FileInfo
.
TIFF
))
{
if
((
fi
==
null
)
||(
fi
.
directory
==
null
)
||
(
fi
.
fileFormat
!=
FileInfo
.
TIFF
))
{
...
@@ -628,7 +659,15 @@ the type of pixel data in this file getPixelType()
...
@@ -628,7 +659,15 @@ the type of pixel data in this file getPixelType()
sb
.
append
(
"}"
);
sb
.
append
(
"}"
);
byte
[]
bstring
=
new
byte
[
Array
.
getLength
(
value
)];
byte
[]
bstring
=
new
byte
[
Array
.
getLength
(
value
)];
for
(
int
i
=
0
;
i
<
bstring
.
length
;
i
++)
bstring
[
i
]=
(
byte
)
Integer
.
parseInt
(
Array
.
get
(
value
,
i
).
toString
());
for
(
int
i
=
0
;
i
<
bstring
.
length
;
i
++)
{
try
{
bstring
[
i
]=
(
byte
)
Integer
.
parseInt
(
Array
.
get
(
value
,
i
).
toString
());
}
catch
(
java
.
lang
.
NumberFormatException
e
)
{
// TODO Auto-generated catch block
// e.printStackTrace();
bstring
[
i
]=(
byte
)
0x3f
;
}
}
// String astring=new String((byte []) value);
// String astring=new String((byte []) value);
String
astring
=
""
;
String
astring
=
""
;
try
{
try
{
...
...
src/main/java/com/elphel/imagej/tileprocessor/QuadCLTCPU.java
View file @
6894dccd
...
@@ -9161,80 +9161,90 @@ public class QuadCLTCPU {
...
@@ -9161,80 +9161,90 @@ public class QuadCLTCPU {
// convert to ImageStack of 3 slices
// convert to ImageStack of 3 slices
// String [] sliceNames = is_mono? new String[]{"mono"}: new String[]{"red", "blue", "green"};
// String [] sliceNames = is_mono? new String[]{"mono"}: new String[]{"red", "blue", "green"};
int
main_color_index
=
is_mono
?
0
:
2
;
int
main_color_index
=
is_mono
?
0
:
2
;
double
[][]
rbg_in
=
is_mono
?
double
[][]
rbg_in
=
is_mono
?
new
double
[][]
{
texture_data
[
0
]}
:
new
double
[][]
{
texture_data
[
0
],
texture_data
[
1
],
texture_data
[
2
]};
new
double
[][]
{
texture_data
[
0
]}
:
double
[]
alpha_pixels
=
null
;
// (0..1.0)
new
double
[][]
{
texture_data
[
0
],
texture_data
[
1
],
texture_data
[
2
]};
if
(
texture_data
.
length
>
rbg_in
.
length
)
{
double
[]
alpha_pixels
=
null
;
// (0..1.0)
alpha_pixels
=
texture_data
[
rbg_in
.
length
];
if
(
texture_data
.
length
>
rbg_in
.
length
)
{
}
else
{
alpha_pixels
=
texture_data
[
rbg_in
.
length
];
alpha_pixels
=
new
double
[
texture_data
[
0
].
length
];
}
for
(
int
i
=
0
;
i
<
alpha_pixels
.
length
;
i
++)
{
if
(!
toRGB
)
{
// Double [][] uses
alpha_pixels
[
i
]
=
Double
.
isNaN
(
rbg_in
[
0
][
i
])
?
0.0
:
1.0
;
ImagePlus
imp
;
}
if
(
alpha_pixels
!=
null
)
{
}
String
[]
titles
=
{
"Y"
,
"alpha"
};
if
(!
toRGB
)
{
// Double [][] uses
ImageStack
stack
=
ShowDoubleFloatArrays
.
makeStack
(
ImagePlus
imp
;
new
double
[][]
{
rbg_in
[
0
],
alpha_pixels
},
// iclt_data,
if
(
alpha_pixels
!=
null
)
{
width
,
// (tilesX + 0) * clt_parameters.transform_size,
String
[]
titles
=
{
"Y"
,
"alpha"
};
height
,
// (tilesY + 0) * clt_parameters.transform_size,
ImageStack
stack
=
ShowDoubleFloatArrays
.
makeStack
(
titles
,
// or use null to get chn-nn slice names
new
double
[][]
{
rbg_in
[
0
],
alpha_pixels
},
// iclt_data,
true
);
// replace NaN with 0.0
width
,
// (tilesX + 0) * clt_parameters.transform_size,
imp
=
new
ImagePlus
(
name
+
suffix
,
stack
);
height
,
// (tilesY + 0) * clt_parameters.transform_size,
imp
.
getProcessor
().
resetMinAndMax
();
titles
,
// or use null to get chn-nn slice names
}
else
{
true
);
// replace NaN with 0.0
ImageProcessor
ip
=
new
FloatProcessor
(
width
,
height
);
imp
=
new
ImagePlus
(
name
+
suffix
,
stack
);
ip
.
setPixels
(
rbg_in
[
0
]);
imp
.
getProcessor
().
resetMinAndMax
();
ip
.
resetMinAndMax
();
}
else
{
imp
=
new
ImagePlus
(
name
+
suffix
,
ip
);
ImageProcessor
ip
=
new
FloatProcessor
(
width
,
height
);
}
ip
.
setPixels
(
rbg_in
[
0
]);
return
imp
;
ip
.
resetMinAndMax
();
}
imp
=
new
ImagePlus
(
name
+
suffix
,
ip
);
String
[]
rgb_titles
=
{
"red"
,
"green"
,
"blue"
};
}
String
[]
rgba_titles
=
{
"red"
,
"green"
,
"blue"
,
"alpha"
};
return
imp
;
String
[]
titles
=
(
alpha_pixels
==
null
)
?
rgb_titles
:
rgba_titles
;
}
int
num_slices
=
(
alpha_pixels
==
null
)
?
3
:
4
;
String
[]
rgb_titles
=
{
"red"
,
"green"
,
"blue"
};
double
mn
=
minmax
[
0
];
// colorProcParameters.lwir_low;
String
[]
rgba_titles
=
{
"red"
,
"green"
,
"blue"
,
"alpha"
};
double
mx
=
minmax
[
1
];
// colorProcParameters.lwir_high;
String
[]
titles
=
(
alpha_pixels
==
null
)
?
rgb_titles
:
rgba_titles
;
ThermalColor
tc
=
new
ThermalColor
(
int
num_slices
=
(
alpha_pixels
==
null
)
?
3
:
4
;
lwir_palette
,
// colorProcParameters.lwir_palette,
if
(
minmax
==
null
)
{
mn
,
minmax
=
new
double
[]
{
Double
.
NaN
,
Double
.
NaN
};
mx
,
for
(
int
i
=
0
;
i
<
rbg_in
[
0
].
length
;
i
++)
if
(!
Double
.
isNaN
(
rbg_in
[
0
][
i
])){
255.0
);
if
(!(
rbg_in
[
0
][
i
]
>=
minmax
[
0
]))
minmax
[
0
]
=
rbg_in
[
0
][
i
];
double
[][]
rgba
=
new
double
[
num_slices
][];
if
(!(
rbg_in
[
0
][
i
]
<=
minmax
[
1
]))
minmax
[
1
]
=
rbg_in
[
0
][
i
];
for
(
int
i
=
0
;
i
<
3
;
i
++)
rgba
[
i
]
=
new
double
[
texture_data
[
main_color_index
].
length
];
}
for
(
int
i
=
0
;
i
<
rbg_in
[
main_color_index
].
length
;
i
++)
{
}
if
(
i
==
160000
)
{
double
mn
=
minmax
[
0
];
// colorProcParameters.lwir_low;
System
.
out
.
println
(
"i="
+
i
);
double
mx
=
minmax
[
1
];
// colorProcParameters.lwir_high;
}
ThermalColor
tc
=
new
ThermalColor
(
double
[]
rgb
=
tc
.
getRGB
(
texture_data
[
main_color_index
][
i
]);
lwir_palette
,
// colorProcParameters.lwir_palette,
rgba
[
0
][
i
]
=
rgb
[
0
];
// red
mn
,
rgba
[
1
][
i
]
=
rgb
[
1
];
// green
mx
,
rgba
[
2
][
i
]
=
rgb
[
2
];
// blue
255.0
);
}
double
[][]
rgba
=
new
double
[
num_slices
][];
if
(
alpha_pixels
!=
null
)
{
for
(
int
i
=
0
;
i
<
3
;
i
++)
rgba
[
i
]
=
new
double
[
texture_data
[
main_color_index
].
length
];
rgba
[
3
]
=
alpha_pixels
;
// 0..1
for
(
int
i
=
0
;
i
<
rbg_in
[
main_color_index
].
length
;
i
++)
{
}
if
(
i
==
160000
)
{
ImageStack
stack
=
ShowDoubleFloatArrays
.
makeStack
(
System
.
out
.
println
(
"i="
+
i
);
rgba
,
// iclt_data,
}
width
,
// (tilesX + 0) * clt_parameters.transform_size,
double
[]
rgb
=
tc
.
getRGB
(
texture_data
[
main_color_index
][
i
]);
height
,
// (tilesY + 0) * clt_parameters.transform_size,
rgba
[
0
][
i
]
=
rgb
[
0
];
// red
titles
,
// or use null to get chn-nn slice names
rgba
[
1
][
i
]
=
rgb
[
1
];
// green
true
);
// replace NaN with 0.0
rgba
[
2
][
i
]
=
rgb
[
2
];
// blue
ImagePlus
imp_rgba
=
EyesisCorrections
.
convertRGBAFloatToRGBA32
(
}
stack
,
// ImageStack stackFloat, //r,g,b,a
if
(
alpha_pixels
!=
null
)
{
// name+"ARGB"+suffix, // String title,
rgba
[
3
]
=
alpha_pixels
;
// 0..1
name
+
suffix
,
// String title,
}
0.0
,
// double r_min,
ImageStack
stack
=
ShowDoubleFloatArrays
.
makeStack
(
255.0
,
// double r_max,
rgba
,
// iclt_data,
0.0
,
// double g_min,
width
,
// (tilesX + 0) * clt_parameters.transform_size,
255.0
,
// double g_max,
height
,
// (tilesY + 0) * clt_parameters.transform_size,
0.0
,
// double b_min,
titles
,
// or use null to get chn-nn slice names
255.0
,
// double b_max,
true
);
// replace NaN with 0.0
0.0
,
// double alpha_min,
ImagePlus
imp_rgba
=
EyesisCorrections
.
convertRGBAFloatToRGBA32
(
1.0
);
// double alpha_max)
stack
,
// ImageStack stackFloat, //r,g,b,a
return
imp_rgba
;
// name+"ARGB"+suffix, // String title,
name
+
suffix
,
// String title,
0.0
,
// double r_min,
255.0
,
// double r_max,
0.0
,
// double g_min,
255.0
,
// double g_max,
0.0
,
// double b_min,
255.0
,
// double b_max,
0.0
,
// double alpha_min,
1.0
);
// double alpha_max)
return
imp_rgba
;
}
}
...
@@ -16328,7 +16338,8 @@ public class QuadCLTCPU {
...
@@ -16328,7 +16338,8 @@ public class QuadCLTCPU {
width
,
// int width, // int tilesX,
width
,
// int width, // int tilesX,
height
,
// int height, // int tilesY,
height
,
// int height, // int tilesY,
debugLevel
);
// int debugLevel )
debugLevel
);
// int debugLevel )
String
preview_path
=
model_dir
+
Prefs
.
getFileSeparator
()
+
title
+
".jpeg"
;
int
jpeg_q
=
correctionsParameters
.
JPEG_quality
;
String
preview_path
=
model_dir
+
Prefs
.
getFileSeparator
()
+
title
+((
jpeg_q
==
0
)?
".tiff"
:
".jpeg"
);
if
(
new
File
(
preview_path
).
exists
()
&&
!
correctionsParameters
.
thumb_overwrite
)
{
if
(
new
File
(
preview_path
).
exists
()
&&
!
correctionsParameters
.
thumb_overwrite
)
{
System
.
out
.
println
(
"file "
+
preview_path
+
" exists, skipping preview generation"
);
System
.
out
.
println
(
"file "
+
preview_path
+
" exists, skipping preview generation"
);
return
false
;
return
false
;
...
@@ -16341,7 +16352,7 @@ public class QuadCLTCPU {
...
@@ -16341,7 +16352,7 @@ public class QuadCLTCPU {
model_dir
,
model_dir
,
false
,
false
,
false
,
false
,
correctionsParameters
.
JPEG_quality
,
// jpegQuality); // jpegQuality){// <0 - keep current, 0 - force Tiff, >0 use for JPEG
jpeg_q
,
// jpegQuality); // jpegQuality){// <0 - keep current, 0 - force Tiff, >0 use for JPEG
(
debugLevel
>
-
2
)
?
debugLevel
:
1
);
// int debugLevel (print what it saves)
(
debugLevel
>
-
2
)
?
debugLevel
:
1
);
// int debugLevel (print what it saves)
return
true
;
return
true
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment