Suppose I want to read an indexed image as it is( not the 3 channel 24 bit images) I wish to read and modify the color palette of an indexed image. In opencv I haven't come across any such functions which extract the color palette of an image! Also I would like to know the datatype of the palette. i am coding in c using opencv Any help?
Access the color palette of an indexed image in C
2.9k views Asked by shiladitya AtThere are 2 answers
KobeJohn
On
Thanks for the image link. First, OpenCV doesn't support GIF (as Ameya005 linked). However there are other indexed palette image formats. It couldn't get an indexed palette image in OpenCV so unless I have missed something, I don't think you are going to be able to work with indexed palettes directly in OpenCV. It sounds like you need an alternative solution. Why do you need to work directly with the indexed palettes?
The second option below though would probably let you have the indexes in OpenCV (the palette would be lost) if that's all you need.
Here is what I've tried:
Load a paletted PNG (gets converted to 3-channel color)
import cv2
im = cv2.imread("mandril_color.png")
im.shape # returns (512, 512, 3) so it's been converted to 3-channel color
Load a paletted GIF (gets converted to grayscale)
I guess this is converting to grayscale with the index used as intensity, but I haven't verified it.
import cv2
import Image
import numpy as np
im_pil = Image.open("mandril_color.gif")
im_cv = np.asarray(im_pil)
im_cv.shape # returns (512, 512) so it's become grayscale
Create a paletted image from scratch in OpenCV
I haven't found any way to do this.
Related Questions in OPENCV
- Creating multiple instances of a class with different initializing values in Flutter
- OpenCV2 on CLion
- How to Draw Chinese Characters on a Picture with OpenCV
- Python cv2 imwrite() - RGB or BGR
- AttributeError: 'Sequential' object has no attribute 'predict_classes'. Did you mean: 'predict_step'?
- Search for an icon on an image OpenCV
- DJI Tello won't follow me
- Python OpenCV and PyGame threading issue
- Need help in Converting Python script (Uses Yolo's pose estimation) to an android app
- Line Segmentation Problem: How to detect lines and draw bounding box of that line on handwritten letters Using CV2
- Configure CmakeLists.txt to avoid manually copying dlls
- How to detect the exact boundary of a Sudoku using OpenCV when there are multiple external boundaries?
- AttributeError: 'Results' object has no attribute 'box'. can anyone explain this?
- How to generate a VPI warpmap for polynomial distortion correction?
- I am trying to make a project of object detection on kaggle notebook using yolo. and i am facing this error. here is my code and my error
Related Questions in GIF
- How to put a gif in a program
- SharePoint - Successfully adding GIFS to a thumbnail in a modern page news article
- Playing gifs bug in flutter
- Is there a way to create a GIF from network images in flutter?
- Java swing problem transparent animation gif
- Animation of geom_circle in ggplot2 displays unintentional interpolated circles
- Desynchronizing GIFs
- Start a Gif on Hover
- How to get an IP address and IP based location of another computer/user embedded on a gif without asking the users permission using javascript?
- How to Adjust Frame Delay for Each Image in Swift when Generating a GIF?
- gif tumbnails goes blank after upload and when used they are still blank
- Can't Detect Gif Selection From TextInput In React Native
- Memory leak issue trying to combine [UIImage] to single GIF image
- Create gif from tiff images and preserve resolution using PIL
- Using saveGif with graphics object in p5.js?
Related Questions in BMP
- How to crop a BMP image in half using C
- Convert Images into Dicom with python
- The Big red X in my C# windows application
- I don't understand what's wrong with the code
- How do i create or edit basic, bmp image using risc-v assembler?
- Read and write BMP image (grayscale)
- Strange base64 python decoding
- GPS neo and Arduino mega 2560 with other sensors
- How to change location of 3x3 cube inside 6x6 cube
- Set pixel color by coordinates (x, y) in 1D byte array
- Unknown reason for malloc "corrupted top size" error
- Yellow Tint on existing BMP Image
- Python: From ESC/P Serial to BMP image
- I get ASCII symbols from BMP header instead numbers
- C++ Bitmap to ASCII, the result is divided in half
Related Questions in COLOR-PALETTE
- My Custom Color Palette just won't take - all grey
- Gnuplot: ramdom but deterministic color palette
- Create new customized color palette for a stacked bar chart with R ggplot
- SDL2 1-bit surface, assign one of two colors in palette to a pixel
- Why is my code using the "Paletteer" package generating an error?
- What is GIMP's algorithm for generating an optimum palette for indexed images?
- Setting colour palette based on month in a %b-%Y variable in ggplot2
- WPF Theming and Colours
- How could you prevent this rgb to colorID conversion from creating 256^3 sized arrays and still keep it vectorized?
- Why can I convert an RGB image to a 17 color palette, but no fewer? (Python Pillow version 10.1.0)
- How can I generate colours from images and set it to background of screen
- Pheatmap: mix range and specific value for color
- Use a maximum of 2 colors from a given palette to update a list of any RGB pixels
- Removing border/outline of colour fill for barplot (scale_fill_manual ggplot2)
- Using multiple continuous colour palettes in one graph (ggplot2 and/or ggfortify)
Related Questions in INDEXED-IMAGE
- I can not solve - A Graphics object cannot be created from an image that has an indexed pixel format error
- How do you output and indexed (black and white) tiff image in opencv
- Colormap doesn't align with indexed image after using rgb2ind
- How to display color indexed image?
- Adjusting brightness and contrast for indexed images
- Convert indexed image colormap to uint8
- Reduce the colors in an image when we already have the palette, using OpenCV
- Convert rgb image to an indexed image without decreasing the colors in Matlab
- Resize indexed PNG image with ImageMagick while preserving color map
- Convert and indexed image to RGB and back without losing data
- save indexed images in MATLAB
- Do indexed Surfaces support palettes with alpha values (other than 255)?
- Is there a way to merge palettes for indexed pygame.Surfaces?
- Applying color palette to Texture
- why different commands result in different indexed color figure
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Well, I don't think OpenCV has any function to do this. The cvLoadImage() or imread() functions use libpng for codecs to directly read images.
Check the documentation for further information
http://opencv.itseez.com/modules/highgui/doc/reading_and_writing_images_and_video.html?highlight=imread#imread