Comments (6)
Hi Pierre,
Thank you for putting this in.
if a color transform is used, planar must be false
if downsampling is used, planar must be true.
otherwise, planar is at the choice of the client
All correct.
In planar
is true, which is easier to explain with YUV, first codestream.pull()
produce Y
for as many Y
rows in the image, then, U
for as many U
rows, then V
.
When planar
is false, which is easier to explain with RGB, first codestream.pull()
produce a row of R
, second pull produce a row of G
, third 'B', and so on.
The parameter comp_num
in codestream.pull(comp_num)
, which is an output parameter, tells you to which component the pulled line belongs.
The following code, taken from ojph_expand, might help explain this.
if (codestream.is_planar())
{
ojph::param_siz siz = codestream.access_siz();
for (ojph::ui32 c = 0; c < siz.get_num_components(); ++c)
{
ojph::ui32 height = siz.get_recon_height(c);
for (ojph::ui32 i = height; i > 0; --i)
{
ojph::ui32 comp_num;
ojph::line_buf *line = codestream.pull(comp_num);
assert(comp_num == c);
base->write(line, comp_num);
}
}
}
else
{
ojph::param_siz siz = codestream.access_siz();
ojph::ui32 height = siz.get_recon_height(0);
for (ojph::ui32 i = 0; i < height; ++i)
{
for (ojph::ui32 c = 0; c < siz.get_num_components(); ++c)
{
ojph::ui32 comp_num;
ojph::line_buf *line = codestream.pull(comp_num);
assert(comp_num == c);
base->write(line, comp_num);
}
}
}
Notice where the color loop is and also notice the assert statement.
Kind regards,
Aous.
from openjph.
Hi Chris,
Thank you for putting this in. I just realized that the term might be confusing. The ultimate objective is not to needlessly buffer lines in the library.
The idea is that if there is no color transform, it is more efficient for the encoder/decoder to process one color component at a time; this is what I call planar because each color plane is fed in sequentially, one line at a time, before the following component's plane. This is the only option available if some color components are downsampled.
If a color transform is used, which requires all the components to have the same downsampling ratio, then the library expects to receive a line from first component, then second, then third, before moving back to the first; this allows the library to perform the color transform. This is what I am calling not-planar (planar = false). This option is also available if no color transform is needed, but it should be less computationally efficient, by a small amount, because it is more likely to have cache evictions.
A line always carries on color component.
I agree that my terminology is not conventional, but I was not very sure how to handle this.
Kind regards,
Aous
from openjph.
The use of planar in this context is confusing, it should be changed or at least documented in the header file. While your explanation is helpful, I am still unsure what it returns when decoding a set_planar(true). Does the output depend on whether or not a color transform is applied? The only HTJ2K color image I have right now is lena from subprojects/js/html/test.j2c.
from openjph.
If color transform is required, set_planar(true) will generate a error message. If color transform is not needed, then set_planar(true) should work fine.
Color transform is required, if it is set in the corresponding marker, and the file has three color components, and they all have the same downsampling ratio.
from openjph.
OK think I understand now, thanks for the clarification!
from openjph.
@aous72 To summarize from the point of view of a client using the decoder:
- if a color transform is used,
planar
must be false - if downsampling is used,
planar
must be true - otherwise,
planar
is at the choice of the client
planar
controls whether codestream.pull()
outputs RRR...RRRGGG...GGGBBB...BBB
(true) or RGBRGB...RGBRGB
(false), where each R,
G,
B` means one line.
Correct (or not)?
from openjph.
Related Issues (20)
- typo in CMakeLists.txt HOT 1
- ojph_compress support for uppercase file extensions HOT 1
- signed 16bit negative values mismatch in interoperablity test between openjph and kakadu HOT 2
- Incorrect COM marker length HOT 1
- openjph decompression fails HOT 2
- Question : what format to be used to decompress the color HTJ2K compressed imaging data HOT 6
- Build should not fail if SIMD optimizations are enabled and your CPU doesn't support them HOT 2
- Feature: Support ROI based rendering HOT 1
- Sample JPH images, please HOT 5
- Unable to build using MinGW HOT 3
- Apple silicon build error HOT 5
- Support decode/expand a j2c file with just tilepart bytes HOT 2
- Tests fails to pass in version 0.10.4 HOT 2
- Specifying non-standard binary and library directories complicates integration in other projects HOT 1
- Feature Request: Add support for vcpkg HOT 1
- Encode 115x25的YUV444 picture,There is serious distortion. HOT 4
- Automated Testing Improvements HOT 1
- Remove xcode specific files HOT 1
- The block coder should be usable without pulling in the rest of OpenJPH HOT 6
- Removing the ojph_ prefix. HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from openjph.