This is an automated email from the ASF dual-hosted git repository.

baunsgaard pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/systemds.git


The following commit(s) were added to refs/heads/main by this push:
     new 88d2e1473e [SYSTEMDS-3545] Image Brightness and Invert
88d2e1473e is described below

commit 88d2e1473e3eee024d66a5c102d819b9dc1127de
Author: baristerzioglu <[email protected]>
AuthorDate: Fri Sep 8 12:53:15 2023 +0200

    [SYSTEMDS-3545] Image Brightness and Invert
    
    This commit adds the Linearized version of Brightness and Invert,
    We did not add tests to these since they can call the default
    brightness and invert functions without modifications.
    
    LDE Project SoSe 2023
    
    Closes #1915
---
 scripts/builtin/img_brightness_linearized.dml      | 38 ++++++++++++++++++++++
 scripts/builtin/img_invert_linearized.dml          | 37 +++++++++++++++++++++
 .../java/org/apache/sysds/common/Builtins.java     |  2 ++
 3 files changed, 77 insertions(+)

diff --git a/scripts/builtin/img_brightness_linearized.dml 
b/scripts/builtin/img_brightness_linearized.dml
new file mode 100644
index 0000000000..1b1433bfa8
--- /dev/null
+++ b/scripts/builtin/img_brightness_linearized.dml
@@ -0,0 +1,38 @@
+#-------------------------------------------------------------
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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.
+#
+#-------------------------------------------------------------
+
+# The img_brightness_linearized-function is an image data augmentation 
function. It changes the brightness of one or multiple images.
+#
+# INPUT:
+# 
-----------------------------------------------------------------------------------------
+# img_in       Input matrix/image (can represent multiple images every row of 
the matrix represents a linearized image)
+# value        The amount of brightness to be changed for the image
+# channel_max  Maximum value of the brightness of the image
+# 
-----------------------------------------------------------------------------------------
+#
+# OUTPUT:
+# 
----------------------------------------------------------------------------------------------------------------------
+# img_out  Output matrix/images  (every row of the matrix represents a 
linearized image)
+# 
----------------------------------------------------------------------------------------------------------------------
+
+m_img_brightness_linearized = function(Matrix[Double] img_in, Double value, 
Integer channel_max) return (Matrix[Double] img_out) {
+  img_out = img_brightness(img_in,value,channel_max)
+}
\ No newline at end of file
diff --git a/scripts/builtin/img_invert_linearized.dml 
b/scripts/builtin/img_invert_linearized.dml
new file mode 100644
index 0000000000..68b245492c
--- /dev/null
+++ b/scripts/builtin/img_invert_linearized.dml
@@ -0,0 +1,37 @@
+#-------------------------------------------------------------
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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.
+#
+#-------------------------------------------------------------
+
+# This is an image data augmentation function. It inverts an image.It can 
handle one or multiple images 
+#
+# INPUT:
+# 
---------------------------------------------------------------------------------------------
+# img_in     Input matrix/image (every row of the matrix represents a 
linearized image)
+# max_value  The maximum value pixels can have
+# 
---------------------------------------------------------------------------------------------
+#
+# OUTPUT:
+# 
-------------------------------------------------------------------------------------------
+# img_out  Output images (every row of the matrix represents a linearized 
image)
+# 
-------------------------------------------------------------------------------------------
+
+m_img_invert_linearized = function(Matrix[Double] img_in, Double max_value) 
return (Matrix[Double] img_out) {
+  img_out = img_invert(img_in,max_value)
+}
diff --git a/src/main/java/org/apache/sysds/common/Builtins.java 
b/src/main/java/org/apache/sysds/common/Builtins.java
index 8ff32ab80c..14c5d8437c 100644
--- a/src/main/java/org/apache/sysds/common/Builtins.java
+++ b/src/main/java/org/apache/sysds/common/Builtins.java
@@ -156,6 +156,7 @@ public enum Builtins {
        IFELSE("ifelse", false),
        IMG_MIRROR("img_mirror", true),
        IMG_BRIGHTNESS("img_brightness", true),
+       IMG_BRIGHTNESS_LINEARIZED("img_brightness_linearized", true),
        IMG_CROP("img_crop", true),
        IMG_TRANSFORM("img_transform", true),
        IMG_TRANSLATE("img_translate", true),
@@ -164,6 +165,7 @@ public enum Builtins {
        IMG_CUTOUT("img_cutout", true),
        IMG_SAMPLE_PAIRING("img_sample_pairing", true),
        IMG_INVERT("img_invert", true),
+       IMG_INVERT_LINEARIZED("img_invert_linearized", true),
        IMG_POSTERIZE("img_posterize", true),
        IMG_POSTERIZE_LINEARIZED("img_posterize_linearized", true),
        IMPURITY_MEASURES("impurityMeasures", true),

Reply via email to