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
- segmentation fault: 11, extracting data in vector
- Disable OpenCL in OpenCV completely
- Python - Writing your own function with opencv giving an error
- Opengl Augmented Reality in Android from solvepnp
- OpenCv Multispectral Image openCV
- Displaying bitmap image on Android (OpenCV)
- Applying homography on non planar surface
- BackgroundSubtractor getBackgroundImage() function return empty Image
- How to choose good SURF feature keypoints?
- opencv python error: Assertion failed (size.width>0 && size.height>0)
- CIDetector to filter rectangle and get cropped image
- How to detect squares in video with OpenCV?
- Python OpenCV error: (-215) size.width>0 && size.height>0 in function imshow
- OpenCV algorithm of contours searching and creation of bounding rectagle
- OpenCV Opening/Closing shifts the positions of the pixels
Related Questions in GIF
- C++ Qt How do you make a label display a movie (gif) that you created using the form?
- How can I add a transparent tkinter image in Python 3.3.2?
- How can I convert PNG to GIF keeping the transparency?
- How to display an animated GIF?
- Tracing out the motion of a double pendulum in gnuplot (and gif conversion)?
- How to resize gif with standard php functions without losing the animation
- What is the most efficient method to make gifs from images using PHP?
- Put a gif in JOptionPane
- Getting path of local image instead of URL Android
- Display animated .gif from URL in JLabel
- Show GIF file with Glide (image loading and caching library)
- Why there's some "noise" around the edge of my loading gif on my website?
- Change Contact Form 7 "SUBMIT" text with animated gif AFTER clicked
- swift Export CAShapeLayer animation to gif
- How to implement animated mask in SVG animation
Related Questions in BMP
- Show 640x480 BMP image with inline ASM c++
- Errors in bitmap creation in Java
- Qt - load bmp565 into QPixmap
- x86 assembly fading bmp with linear interpolation
- BMP Image Compression and Decompression in java
- Create BMP header in C (can't limit 2 byte fields)
- C# trying to type text on a .bmp
- How to get bmp image from from binary blob data with php
- cannot save file because it's in use
- How can I retrieve an image data buffer from clipboard memory (uintptr)?
- How to create bmp file from hex data in python?
- .BMP file cannot be opened
- I have a RGBA image file which I want to convert to BMP in C++
- How to save graphic to bmp
- How do I write raw pixel data and save as a bitmap
Related Questions in COLOR-PALETTE
- html5 canvas circle palette
- Grabbing color palette from YouTube thumbnail
- PBO Indexed Color Texture Rendering with Palette in Fragment Shader not working
- HTML5 Canvas circle palette need custom size
- Abstract fields implemented by static final class?
- How do I combine similar elements in a list in python?
- How to read a palette image as a scalar image with ITK?
- Change size array in ColorPalette.Entries
- error: Error: No resource found that matches the given name: attr 'colorAccent'
- Multiple palettes and empty labels from file entries using matrix with image in gnuplot
- Display custom color dialog directly- JavaFX ColorPicker
- Simple swift color picker popover (iOS)
- How can I attach a list of custom color palettes to a list of ggplot objects without printing each plot object to the screen?
- Use a color palette for matrix points in UpSetR
- How do I make a lighter version of a colour using PHP?
Related Questions in INDEXED-IMAGE
- Convert indexed image colormap to uint8
- Is there a way to merge palettes for indexed pygame.Surfaces?
- Python PIL: Create indexed color image with transparent background
- Indexed color using Android's graphics API
- How do I determine if an indexed mode SDL_Surface has transparency or not?
- Converting an indexed image in uint32 to double
- Adjusting brightness and contrast for indexed images
- Applying color palette to Texture
- Colormap doesn't align with indexed image after using rgb2ind
- Capture screenshot of program using indexed color table
- How do you output and indexed (black and white) tiff image in opencv
- Convert and indexed image to RGB and back without losing data
- Resize indexed PNG image with ImageMagick while preserving color map
- Graphics on indexed image
- Do indexed Surfaces support palettes with alpha values (other than 255)?
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