Repository: opencv
Issue: Support palette-based images in imwrite (Compression does not seem to be working for PNG images)
Labels: feature,priority: low,category: imgcodecs

##### System information (version)
<!-- Example
- OpenCV => 4.2
- Operating System / Platform => Windows 64 Bit
- Compiler => Visual Studio 2017
-->

- OpenCV => JavaCV version that I am using - 1.5.3
- Operating System / Platform => :grey_question:
- Compiler => Java 11

##### Detailed description

I m trying to compress the PNG images , and have tried to use different COMPRESSION algorithm , but the image file size remains the same. The image I m using is https://upload.wikimedia.org/wikipedia/commons/d/d7/Astro_4D_stars_proper_radial_g_b_8mag_big.png

Before resize length 1966656
After resize length IMWRITE_PNG_STRATEGY_HUFFMAN_ONLY - 6355730
After resize length IMWRITE_PNG_STRATEGY_FILTERED - 6355730
After resize length IMWRITE_PNG_STRATEGY_FIXED 6355730
After resize length IMWRITE_PNG_STRATEGY_RLE 6355730
The resizing(decreasing the dimension) is increasing the size of the image after the first log.

##### Steps to reproduce

I am using Java for this-
```
resizeByThird(sourceImage: Path, destinationImage: Path) {
        val sourceImageMat = imread(sourceImage.toString())
        val resizedImage = Mat()
        resize(sourceImageMat, resizedImage, Size(3840, 2208))
        println(sourceImage.toFile().length())
        val params: IntArray = intArrayOf(IMWRITE_PNG_STRATEGY_HUFFMAN_ONLY)
        imwrite(destinationImage.toString(), resizedImage, params)
        println(destinationImage.toFile().length())
    }
```

I discussed this on the community channel-  https://answers.opencv.org/question/231829/compression-algo-not-helpful-in-png-cases/
##### Issue submission checklist

 - [ ] I report the issue, it's not a question
   <!--
   OpenCV team works with answers.opencv.org, Stack Overflow and other communities
   to discuss problems. Tickets with question without real issue statement will be
   closed.
   -->
 - [ ] I checked the problem with documentation, FAQ, open issues,
       answers.opencv.org, Stack Overflow, etc and have not found solution
   <!--
   Places to check:
   * OpenCV documentation: https://docs.opencv.org
   * FAQ page: https://github.com/opencv/opencv/wiki/FAQ
   * OpenCV forum: https://answers.opencv.org
   * OpenCV issue tracker: https://github.com/opencv/opencv/issues?q=is%3Aissue
   * Stack Overflow branch: https://stackoverflow.com/questions/tagged/opencv
   -->
 - [ ] I updated to latest OpenCV version and the issue is still there
   <!--
   master branch for OpenCV 4.x and 3.4 branch for OpenCV 3.x releases.
   OpenCV team supports only latest release for each branch.
   The ticket is closed, if the problem is not reproduced with modern version.
   -->
 - [ ] There is reproducer code and related data files: videos, images, onnx, etc
   <!--
   The best reproducer -- test case for OpenCV that we can add to the library.
   Recommendations for media files and binary files:
   * Try to reproduce the issue with images and videos in opencv_extra repository
     to reduce attachment size
   * Use PNG for images, if you report some CV related bug, but not image reader
     issue
   * Attach the image as archite to the ticket, if you report some reader issue.
     Image hosting services compress images and it breaks the repro code.
   * Provide ONNX file for some public model or ONNX file with with random weights,
     if you report ONNX parsing or handling issue. Architecture details diagram
     from netron tool can be very useful too. See https://lutzroeder.github.io/netron/
   -->