I want to speed up the process of composite composition.
We have achieved this, but I want to shorten the processing time.
// composite composition
private fun composite(srcImg1 :Bitmap ,srcImg2 :Bitmap) :Bitmap (
// image
var dstImg1 :Bitmap = Bitmap.createBitmap(srcImg1.width, srcImg1.height, Bitmap.Config.ARGB_8888)
// height width
val width1 :Int = dstImg1.width
val height1 :Int = dstImg1.height
// illuminance
var rgb1 :Int
var gray1 :Int
var rgb2: Int
var gray2 :Int
// composite composite adopt brighter one
for(j in 0..height1-1 step 1) {
for (i in 0..width1-1 step 1) {
rgb1 = srcImg1.getPixel(i, j)
rgb2 = srcImg2.getPixel(i, j)
gray1 = (Color.red(rgb1) * 0.3 + Color.green(rgb1) * 0.59 + Color.blue(rgb1) * 0.11).toInt()
gray2 = (Color.red(rgb2) * 0.3 + Color.green(rgb2) * 0.59 + Color.blue(rgb2) * 0.11).toInt()
if (gray1 >= gray2){
dstImg1.setPixel(i, j, Color.rgb(Color.red(rgb1), Color.green(rgb1), Color.blue(rgb1)))
}else{
dstImg1.setPixel(i, j, Color.rgb(Color.red(rgb2), Color.green(rgb2), Color.blue(rgb2)))
}
}
}
return dstImg1
}
3. Processing time
Terminal 1: P10
Image Size: 6048 * 3402 = 20575296
Processing time: 17984msec About 17 seconds *Measure the time with the above function in between
Roughly 1 pixel processing time: 0.874msec
Terminal 2: oppo
Image Size: 4608 * 2592 = 11943936
Processing time: 14119msec About 14 seconds *Measure the time with the above function in between
Roughly 1 pixel processing time: 1.18msec
Calculated by image size/processing time
4. QuestionSince the height direction and the width direction are turned with for, it will take considerably time if the image size becomes large.
I would like to reduce this time to 1/10 if possible, but is there any other way?
I couldn't think of any other way, so I searched for another way on the net, but couldn't find it,
I have a question on this site.
Android Studio 3.6.3
Language: kotlin
Based on: Camera2Basic (kotlin)
Terminal 1: P10
Terminal 2: oppo A5 2020
It would be very helpful if you have any information or would like to try this and give us a comment.
-
Answer # 1
Related articles
- android - how to make a sound [kotlin]
- android - kotlin: how to perform https communication by referring to the ssl certificate in the terminal
- android studio - [kotlin app development] i want to make the specifications so that the number of buttons increases each time th
- android - [kotlin] unresolved reference: dialogbuttonclicklistener () cannot be resolved
- android - how to study kotlin
- android studio - [kotlin] there is activity_loginxml, but i get an unresolved reference: activity_login error
- kotlin - i want to conditionally branch list data for android application development and display it in a sorted manner
- kotlin - i want to conditionally branch list data for android application development and display it in a sorted manner
- i want to process like a switch statement in kotlin
- android - about display of kotlin images
- kotlin android implements onclicklistener on acitivity and overrides onclick, but there is no response when clicked
- android - [kotlin] app is forced to close due to screen transition when list is pressed
- android - can unity, swift and kotlin coexist?
- Android uses Kotlin to implement multi-node progress bar
- The implementation of Android studio generation with Kotlin documents
- Android Studio kotlin generates editing class comment code
- android - kotlin todo app
- Android Studio Kotlin code and java code conversion example
- Detailed Android Studio 36 installation process and AVD installation and operation steps
- java : How to find Kotlin code in a project
- android : Errors when parsing xml via simplexml converter to retrofit
- android : How to use recyclerview item as button in Kotlin
- java : TextInputLayout overrides the hint property
- android : The names of all files in the folder should be recorded, and only the name of the first (Kotlin) is recorded
- android : Rotating text on canvas
- android : Insert in afterTextChanged is not triggered correctly by the line length condition
- android : Kotlin get time from server
- android : How to transfer a list to a Spinner depending on the selected item in another Spinner?
- android : How to make code return Unit and not String (Kotlin)
This is the content of this composite composition.
I hope it will be helpful.