Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Take decode arrays into account when processing grayscale images #159

Merged
merged 4 commits into from
Aug 30, 2019
Merged

Take decode arrays into account when processing grayscale images #159

merged 4 commits into from
Aug 30, 2019

Conversation

adrg
Copy link
Collaborator

@adrg adrg commented Aug 28, 2019

Some of the image extraction test case files contain custom decode arrays for grayscale images.
The default decode array for grayscale images is [0.0 1.0] which means that 0.0 is black and 1.0 is white. Some of the files had reversed decode arrays [1.0 0.0] which basically means that 0.0 is white and 1.0 is black. As a result, the images in cause were not exported as they are in the test PDF files.

Specifications URL


This change is Reviewable

@CLAassistant
Copy link

CLAassistant commented Aug 28, 2019

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@kucjac kucjac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 3 files reviewed, 1 unresolved discussion (waiting on @adrg)


model/image.go, line 92 at r1 (raw file):

	data := img.Data
	lenData := len(img.Data)
	maxVal := math.Pow(2, float64(img.BitsPerComponent)) - 1

How about changing the math.Pow with (uint32(1) << img.BitsPerComponent) - 1? The arithmetic shift is one of the processors instructions, and it is a good practice to use it for operations that gets the powers of 2.

Copy link
Collaborator Author

@adrg adrg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 4 files reviewed, 1 unresolved discussion (waiting on @kucjac)


model/image.go, line 92 at r1 (raw file):

Previously, kucjac (Jacek Kucharczyk) wrote…

How about changing the math.Pow with (uint32(1) << img.BitsPerComponent) - 1? The arithmetic shift is one of the processors instructions, and it is a good practice to use it for operations that gets the powers of 2.

Done.

@gunnsth gunnsth merged commit 56e81d3 into unidoc:development Aug 30, 2019
@adrg adrg deleted the gray-images-decode-arrays branch September 2, 2019 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants