Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openbis
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sispub
openbis
Commits
96459788
Commit
96459788
authored
10 years ago
by
jakubs
Browse files
Options
Downloads
Patches
Plain Diff
SSDM-363 Added white point normalization for the resulting mix image
SVN: 31578
parent
f0846ccb
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
common/source/java/ch/systemsx/cisd/common/image/MixColors.java
+41
-19
41 additions, 19 deletions
.../source/java/ch/systemsx/cisd/common/image/MixColors.java
with
41 additions
and
19 deletions
common/source/java/ch/systemsx/cisd/common/image/MixColors.java
+
41
−
19
View file @
96459788
...
@@ -18,7 +18,6 @@ package ch.systemsx.cisd.common.image;
...
@@ -18,7 +18,6 @@ package ch.systemsx.cisd.common.image;
import
java.awt.Color
;
import
java.awt.Color
;
import
java.awt.image.BufferedImage
;
import
java.awt.image.BufferedImage
;
import
java.awt.image.ColorModel
;
import
org.apache.log4j.Logger
;
import
org.apache.log4j.Logger
;
...
@@ -274,14 +273,51 @@ public class MixColors
...
@@ -274,14 +273,51 @@ public class MixColors
int
width
=
images
[
0
].
getWidth
();
int
width
=
images
[
0
].
getWidth
();
int
height
=
images
[
0
].
getHeight
();
int
height
=
images
[
0
].
getHeight
();
final
BufferedImage
mixed
=
new
BufferedImage
(
width
,
height
,
BufferedImage
.
TYPE_INT_RGB
);
for
(
int
y
=
0
;
y
<
images
[
0
].
getHeight
();
++
y
)
final
Color
[][]
notNormalizedPixels
=
new
Color
[
width
][
height
];
float
whitePointSumIntencity
=
0
f
;
Color
whitePointColor
=
new
Color
(
0
);
final
float
[]
mixedComponents
=
new
float
[
4
];
// store the colours and calculate white point
for
(
int
y
=
0
;
y
<
height
;
++
y
)
{
{
for
(
int
x
=
0
;
x
<
images
[
0
].
getW
idth
()
;
++
x
)
for
(
int
x
=
0
;
x
<
w
idth
;
++
x
)
{
{
Color
mixColor
=
mergeColorsAlgorithm
.
merge
(
colors
,
x
,
y
,
images
);
Color
mixColor
=
mergeColorsAlgorithm
.
merge
(
colors
,
x
,
y
,
images
);
mixed
.
setRGB
(
x
,
y
,
mixColor
.
getRGB
());
notNormalizedPixels
[
x
][
y
]
=
mixColor
;
mixColor
.
getRGBColorComponents
(
mixedComponents
);
float
sumIntencity
=
0
f
;
for
(
int
i
=
0
;
i
<
mixedComponents
.
length
;
i
++)
{
sumIntencity
+=
mixedComponents
[
i
];
}
if
(
whitePointSumIntencity
<
sumIntencity
)
{
whitePointColor
=
mixColor
;
whitePointSumIntencity
=
sumIntencity
;
}
}
}
final
float
whitePointFactor
=
255
f
/
getMaxComponent
(
whitePointColor
.
getRed
(),
whitePointColor
.
getGreen
(),
whitePointColor
.
getBlue
());
final
BufferedImage
mixed
=
new
BufferedImage
(
width
,
height
,
BufferedImage
.
TYPE_INT_RGB
);
// apply white point adjustments to the final image
for
(
int
y
=
0
;
y
<
height
;
++
y
)
{
for
(
int
x
=
0
;
x
<
width
;
++
x
)
{
notNormalizedPixels
[
x
][
y
].
getRGBColorComponents
(
mixedComponents
);
for
(
int
i
=
0
;
i
<
mixedComponents
.
length
;
i
++)
{
mixedComponents
[
i
]
*=
whitePointFactor
;
}
mixed
.
setRGB
(
x
,
y
,
new
Color
(
images
[
0
].
getColorModel
().
getColorSpace
(),
mixedComponents
,
1
).
getRGB
());
}
}
}
}
return
mixed
;
return
mixed
;
...
@@ -326,20 +362,6 @@ public class MixColors
...
@@ -326,20 +362,6 @@ public class MixColors
for
(
int
i
=
0
;
i
<
numberOfImages
;
++
i
)
for
(
int
i
=
0
;
i
<
numberOfImages
;
++
i
)
{
{
isGrayscale
=
isGrayscale
&&
images
[
i
].
getColorModel
().
getNumColorComponents
()
==
1
;
isGrayscale
=
isGrayscale
&&
images
[
i
].
getColorModel
().
getNumColorComponents
()
==
1
;
ColorModel
colorModel
=
images
[
i
].
getColorModel
();
int
componentSize
;
try
{
componentSize
=
colorModel
.
getComponentSize
(
0
);
}
catch
(
NullPointerException
e
)
{
operationLog
.
info
(
"Could not determine the componentSize of an image. Potentially using non 8-bit image in merging"
);
continue
;
}
if
(
componentSize
!=
8
)
{
throw
new
IllegalArgumentException
(
"Only 8-bit images can be merged."
);
}
}
}
return
createColorMergingAlgorithm
(
quadratic
,
saturationEnhancementFactor
,
isGrayscale
,
return
createColorMergingAlgorithm
(
quadratic
,
saturationEnhancementFactor
,
isGrayscale
,
numberOfImages
);
numberOfImages
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment