Commit Graph

24 Commits

Author SHA1 Message Date
Kumataro
35dbf32227
Merge pull request #26211 from Kumataro:fix26207
imgcodecs: implement imencodemulti() #26211

Close #26207
### Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [x] The PR is proposed to the proper branch
- [x] There is a reference to the original bug report and related work
- [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [x] The feature is well documented and sample code can be built with the project CMake
2024-10-18 14:44:55 +03:00
zihaomu
934e6899f8
Merge pull request #25809 from zihaomu:imread_rgb_flag
imgcodecs: Add rgb flag for imread and imdecode #25809

Try to `imread` images by RGB to save R-B swapping costs.

## How to use it?
```
img_rgb = cv2.imread("PATH", IMREAD_COLOR_RGB) # OpenCV decode the image by RGB format.
```

## TODO
- [x] Fix the broken code
- [x] Add imread rgb test
- [x] Speed test of rgb mode.

## Performance test

| file name | IMREAD_COLOR  | IMREAD_COLOR_RGB |
| --------- | ------ | --------- |
| jpg01     | 284 ms | 277 ms    |
| jpg02     | 376 ms | 366 ms    |
| png01     | 62 ms  | 60 ms     |
| Png02     | 97 ms  | 94 ms     |

Test with [image_test.zip](https://github.com/user-attachments/files/15982949/image_test.zip)
```.cpp
string img_path = "/Users/mzh/work/data/image_test/png02.png";
int loop = 20;

TickMeter t;

double t0 = 10000;
for (int i = 0; i < loop; i++)
{
    t.reset();
    t.start();
    img_bgr = imread(img_path, IMREAD_COLOR);
    t.stop();

    if (t.getTimeMilli() < t0) t0 = t.getTimeMilli();
}

std::cout<<"bgr time = "<<t0<<std::endl;

t0 = 10000;
for (int i = 0; i < loop; i++)
{
    t.reset();
    t.start();
    img_rgb = imread(img_path, IMREAD_COLOR_RGB);
    t.stop();
    if (t.getTimeMilli() < t0) t0 = t.getTimeMilli();
}
std::cout<<"rgb time = "<<t0<<std::endl;
``` 
### Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [x] The PR is proposed to the proper branch
- [ ] There is a reference to the original bug report and related work
- [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [ ] The feature is well documented and sample code can be built with the project CMake
2024-07-03 10:58:25 +03:00
Maksim Shabunin
b77c74b6fc imgproc: fixed imread with output image argument, minor refactoring, fixes in HDR 2024-06-04 19:52:22 +03:00
Suleyman TURKMEN
7d6b6161cc Update imgcodecs tests 2024-05-15 22:24:21 +03:00
Alexander Alekhin
b16f76eede Merge remote-tracking branch 'upstream/3.4' into merge-3.4 2022-12-03 12:39:41 +00:00
Alexander Alekhin
f0df78b7e7 imgcodecs: ensure parameters are key-value pairs, fix HDR encoder 2022-11-20 13:08:46 +00:00
Alexander Smorkalov
04ebedb6f0
Merge pull request #22128 from ocpalo:multipage_img_decoder
[GSoC 2022] Multipage Image Decoder API
2022-09-21 16:10:22 +03:00
Berke
062cee2933 new multipage image decoder api - ImageCollection 2022-09-19 20:27:01 +03:00
Berke
3929e26276 spng encoder/decoder added as optional png codec 2022-08-29 00:03:43 +03:00
Vadim Levin
bce5d364df feat: change OpenJPEG encoder to lossy with default parameters 2020-08-27 15:11:45 +03:00
Alexander Alekhin
524a2fffe9 Merge remote-tracking branch 'upstream/3.4' into merge-3.4 2020-07-06 23:05:04 +00:00
Maksim Shabunin
e8129429e9 imgcodecs: fix test build with disabled JPEG and PNG libs 2020-07-06 14:52:52 +03:00
Alexander Alekhin
cf2a3c8e74 Merge remote-tracking branch 'upstream/3.4' into merge-3.4 2020-04-02 21:52:32 +00:00
Alexander Alekhin
6d85fa3fd2 imgcodecs(test): rework common I/O test, added grayscale mode 2020-03-27 21:34:51 +00:00
StefanBruens
8d78400052
Merge pull request #16494 from StefanBruens:jpeg2000_openjpeg_port
Jpeg2000 OpenJPEG port

* OpenJPEG based JPEG2000 decoder implementation

Currently, the following input color spaces and depth conversions are
supported:

- 8 bit -> 8 bit
- 16 bit -> 16 bit (IMREAD_UNCHANGED, IMREAD_ANYDEPTH)

- RGB(a) -> BGR
- RGBA -> BGRA (IMREAD_UNCHANGED)
- Y(a) -> Y(a) (IMREAD_ANYCOLOR, IMREAD_GRAY, IMREAD_UNCHANGED))
- YCC -> Y (IMREAD_GRAY)

* Check for OpenJPEG availability

This enables OpenJPEG based JPEG2000 imread support by default, which
can be disabled by -DWITH_OPENJPEG=OFF. In case OpenJPEG is enabled
and found, any checks for Jasper are skipped.

* Implement precision downscaling for precision > 8 without IMREAD_UNCHANGED

With IMREAD_UNCHANGED, values are kept from the input image, without it
components are downscaled to CV_8U range.

* Enable Jpeg2K tests when OpenJPEG is available

* Add support for some more color conversions

Support IMREAD_GRAY when input color space is RGB or unspecified.
Support YUV input color space for BGR output.

* fix: problems with unmanaged memory

* fix: CMake warning - HAVE_OPENJPEG is undefined

Removed trailing whitespaces

* fix: CMake find_package OpenJPEG add minimal version

* Basic JPEG2K encoder

Images with depth CV_8U and CV_16U are supported, with 1 to 4 channels.

* feature: Improved code for OpenJPEG2000 encoder/decoder

 - Removed code duplication
 - Added error handlers
 - Extracted functions

* feature: Update conversion openjpeg array from/to Mat

* feature: Extend ChannelsIterator to fulfill RandomAccessIterator named requirements

 - Removed channels split in copyFromMatImpl. With ChannelsIterator no allocations are performed.
 - Split whole loop into 2 parts in copyToMat -> where std::copy and std::transforms are called.

* fix: Applied review comments.

 - Changed `nullptr` in CV_LOG* functions to `NULL`
 - Added `falls through` comment in decoder color space `switch`
 - Added warning about unsupported parameters for the encoder

* feature: Added decode from in-memory buffers.

Co-authored-by: Vadim Levin <vadim.levin@xperience.ai>
2020-03-27 07:18:58 +00:00
Ganesh Kathiresan
80ade96c8c Merge pull request #16309 from ganesh-k13:bugfix/imdecode-resize
* Added flag handlers for imread and imdecode | Issue 16203

Undo imread change

Added Imread resize tests

Added imdecode flags check

Added imdecode tests for resize

Removed trailing whitespace

Removed IMREAD_IGNORE_ORIENTATION check

Added else condition

Removed IMREAD_IGNORE_ORIENTATION check in decode

Added HAVE_JPEG guards

Added static_cast for Win32

Added resize for non jpegs

Added tests for non jpeg resize case

Fixed resize value in assert

Changed tests to Value-Parameterized Tests

Changed tests to Value-Parameterized Tests | handled >> in cpp

Changed tests to Value-Parameterized Tests | removed trailing whitespace

* imgcodecs: update test
2020-01-20 14:00:45 +03:00
Alexander Alekhin
43c68d1864 imgcodecs: OPENCV_IO_ENABLE_JASPER runtime parameter 2019-03-14 21:43:24 +00:00
Alexander Enaldiev
84584002f2 Merge pull request #11417 from Turim:imgcodecs_cmake_decoders_customize_formats
* imgcodecs cmake: the option to customize supported formats list (WITH_IMGCODEC_HDR, WITH_IMGCODEC_SUNRASTER, WITH_IMGCODEC_PXM)

* imgcodecs: fixes

- fixed CMake scripts (=OFF doesn't really work)
- restore dropped GDCM block
- added _IMGCODEC_ prefix
- fixed tests
- include PAM format under WITH_IMGCODEC_PXM option
2018-05-22 15:10:15 +00:00
catree
a885480c9e Remove temporary file used for test. 2018-03-29 18:34:30 +02:00
RAJKIRAN NATARAJAN
6d83a80385 Merge pull request #11176 from saskatchewancatch:issue-11165
* fix cv::imwrite to allow cv::UMat and vectors of it to be written

* cv::imwrite failure handling improvements

* Unit test for regression testing imwrite support for and fix whitespace
2018-03-29 16:47:31 +03:00
Alexander Alekhin
4a297a2443 ts: refactor OpenCV tests
- removed tr1 usage (dropped in C++17)
- moved includes of vector/map/iostream/limits into ts.hpp
- require opencv_test + anonymous namespace (added compile check)
- fixed norm() usage (must be from cvtest::norm for checks) and other conflict functions
- added missing license headers
2018-02-03 19:39:47 +00:00
Alexander Alekhin
8f05126619 imgcodecs: fix regression 9376 2017-08-29 13:31:26 +03:00
Alexander Alekhin
78a310630f imgproc(test): add checks for remove() call 2017-08-16 18:56:42 +03:00
Maksim Shabunin
87b569d812 Rewritten some tests in videoio and imgcodecs modules
general:
- all iterative tests have been replaced with parameterized tests
- old-style try..catch tests have been modified to use EXPECT_/ASSERT_ gtest macros
- added temporary files cleanup
- modified MatComparator error message formatting

imgcodecs:
- test_grfmt.cpp split to test_jpg.cpp, test_png.cpp, test_tiff.cpp, etc.

videoio:
- added public HAVE_VIDEO_INPUT, HAVE_VIDEO_OUTPUT definitions to cvconfig.h
- built-in MotionJPEG codec could not be tested on some platforms (read_write test was disabled if ffmpeg is off, encoding/decoding was handled by ffmpeg otherwise).
- image-related tests moved to imgcodecs (Videoio_Image)
- several property get/set tests have been combined into one
- added MotionJPEG test video to opencv_extra
2017-06-20 18:20:41 +03:00