I want to substitute LSB of rgb image with character. I have done it for gray sacle image using bitset and bitget. Can I use same logic for rgb image?
Here is part of code which I have used:
stego=zeros(size(img))
stego=bitset(stego,1,lsp)
Where img is cover image and lsp is binary message. I have then merge bitplanes by:
stego=bitset(stego,2,bitget(img,2))
Up to 8th plane to get the strgo image.
How can I build the same logic for RGB image? Please guide me.
Related
Is it possible to construct a png image, that is entirely opaque (that means every pixel in the image is opaque) but the image data itself has an alpha channel ?
Why is it that some PNG images don't have an alpha channel ?
Yes. Just like an RGB image may contain only data in the Red channel and not in Green and Blue; "unused" channels are not a problem. Alpha is a separate channel of its own, and in particular, its values should be independent of the associated pixel colors: "PNG does not use premultiplied alpha" (6.2 Alpha representation).
Also see 12.4 Alpha channel creation in the official specifications for some additional details:
The alpha channel can be regarded either as a mask that temporarily hides transparent parts of the image, or as a means for constructing a non-rectangular image. In the first case, the colour values of fully transparent pixels should be preserved for future use. In the second case, the transparent pixels carry no useful data and are simply there to fill out the rectangular image area required by PNG. In this case, fully transparent pixels should all be assigned the same colour value for best compression.
Because they don't need to, per that same specification:
... PNG provides a patent-free replacement for GIF and can also replace many common uses of TIFF. Indexed-color, grayscale, and truecolor images are supported, plus an optional alpha channel. (my emphasis)
I have an gray scale image of size <2559x3105 uint16>. when I try to open this image, I get warning that it is too big. I have tried imresize() function to make it small<512x512 uint8> in size. When I plot the original image and re-sized image, the intensity gets decreased after re-sizing. I want to re-size original image without changing in its pixel values. Is there any solution?
If you would like to keep your final image as uint8, I think you would be needed to first convert the uint16 image to uint8 image using im2uint8 -
uint8_image = im2uint8(uint16_image);
Then you may apply imresize on uint8_image.
But, if you don't want your final image to be of uint8 type, you can directly use imresize and it would keep the datatype, i.e. the resized image would be of uint16 type.
Read the docs and use the nearest neighbor method. That is,
resized = imresize(original, scale, 'nearest')
This will not use interpolated values. The downside is of course that edges might be jagged.
It sounds like your 16-bit image uses linear codes while the resulting 8-bit image needs to be gamma corrected. If this is the case you can use imadjust with a gamma parameter of 1/2.2 to produce the brighter image.
Do you get the warning when you display it with imshow? Does it say something like "Image to large to fit the screen, resizing to xx%"? If so, then you can simply ignore the warning. Otherwise, you can can set the 'InitialMagnification' parameter of imshow to resize the figure, but not the image itself.
I discovered that CGBitmapContextCreateImage() creates an image, which is not neccessarily always a mask compatible with CGContextClipToMask(). But when using CGImageMaskCreate(), the CGImageRef is always a mask that works with CGContextClipToMask(). Now, what is so special about the mask VS. the "normal" image?
My guess is that the mask is grayscale only, where as an CGImageRef created with CGBitmapContextCreateImage() may have RGBA values which irritate CGContextClipToMask(). I couldn't find the spot in the documentation where the exact difference between masks and CG images is explained.
But it seems that an Core Graphics image != a mask, while a mask == a Core Graphics Image
Every value in an image, be it RGB, CMYK or Greyscale, represents a position in a particular colorspace. It is meaningful to ask "What would this value be in colour-space 'x'?" - and the result would, if possible, be the same colour, but could be a different numerical value.
eg (simplistically). A pixel with value (255,255,255) is White in an RGB colorspace but Black in a (hypothetical) CMY colour-space. Converting the White RGB pixel to the CMY colorspace would give the value (0,0,0). In other words an Image must have a colorspace, it only makes sense given a colorspace.
On the contrary, an 8bit mask represents absolute values between 0-255. There is no colorspace and it makes no sense to think of a mask in a particular colorspace.
In that way images and masks are fundamentally different, even though we often think of masks as greyscale images.
An image mask in Core Graphics is a special kind of image. From the CGImageMaskCreate reference:
A Quartz bitmap image mask is used the same way an artist uses a silkscreen, or a sign painter uses a stencil. The bitmap represents a mask through which a color is transferred. The bitmap itself does not have a color. It gets its color from the fill color currently set in the graphics state.
When you draw into a context with a bitmap image mask, Quartz uses the mask to determine where and how the current fill color is applied to the image rectangle. Each sample value in the mask specifies how much of the current fill color is masked out at a specific location. Effectively, the sample value specifies the opacity of the mask. Larger values represent greater opacity and hence less color applied to the page.
See more here: http://developer.apple.com/library/mac/#documentation/GraphicsImaging/Reference/CGImage/Reference/reference.html
I'll do the medical image processing with CLAHE method (I use the code in http://www.mathworks.com/matlabcentral/fileexchange/22182-contrast-limited-adaptive-histogram-equalization-clahe/all_files ) and region growing ( http://www.mathworks.com/matlabcentral/fileexchange/19084-region-growing/content/regiongrowing.m )
that function can run if i use double data type for image. but converting image to double make its to be the binary image.
anyone know how to make image still in double but not to be a binary image?
If your image is img then do im2double(img). See im2double on the mathworks reference site.
If I've understood your comment correctly, you're trying to convert a binary image to a gray scale image. If so, this is not possible, as you've thrown away all the intensity information in lieu of a simple 0/1 image.
If your question was on how to convert a color/grayscale image to double, then LightningIsMyName has the answer for you. Here's a small example that you can play around with to see what you really want:
img=imread('peppers.png'); %#read in MATLAB's stock image
imgDouble=im2double(img); %#convert uint8 to double
imgGray=rgb2gray(img); %#convert RGB image to grayscale
imgGrayDouble=im2double(imgGray);%#convert grayscale image to double.
Here's how your color and grayscale images should look like:
I am using CGColorSpaceCreateDeviceRGB() which returns a png image(pixel format)? Is there a way to save this image as a vector image. Basically I need to save the pictures drawn by the GLPaint application as a vector image.
I don't know anything about this function or about GLPaint, but you can't take a pixellized image and turn it into a vector image. Only humans and highly clever algorithms can do that ( see http://vectormagic.com/ )
If you have access to the input (gestures?) of GLPaint, you should convert them to SVG directly instead of passing through an RGB image.