I'm working on steganography in binary image.but I have a problem in implementation in matlab.
I want to konw that,
How can I hide a message in a binary image?
And,
How can I do it in matlab with m-file or simulation?
Steganography can be done in so many different ways that you will have to define what exactly do you need if you want something specific.
In the mean time here is an example:
Encoding:
take an image and make each pixel uses only 23 out of 24 bits for colors (for example set lowest bit to 0 on the value of red color)
this will give you W x H bits for your message
put your message bit by bit into cleared pixels
Decoding
extract only bits from the lowest bit red component in the order they were put in and... that's it.
There was recently a similar question on SO with great answer from #Jacob with code example.
You can also have a look at LSB Based Steganography article on Advanced Matlab website.
Try to check image Steganography using LSB then you will be knowing how to implement. I have try that for my project.
[fn, pn, FI] = uigetfile('*.jpg*','Select the Cover Image','multiselect','on');
coln=size(fn,2);
numberfile=coln;
for i=1:numberfile
fn(i);
entirefile=fullfile(pn,fn{i});
fid=fopen(entirefile);
fclose(fid);
end
I = imread([pn,fn{i}]);
fprintf('Cover Image Loaded ... \n\n')
[fn, pn] = uigetfile('*.txt','Select Text File')
This code is just for example how to implement, i use to select multiple frames, you use according to your need.
Related
I'm using GMM to fit my data to 256 Gaussians. I'm using Matlab's fitgmdist to achieve this.
gmm{i} = fitgmdist(model_feats, gaussians, 'Options',statset('MaxIter',1000), ...
'CovType','diagonal', 'SharedCov',false, 'Regularize',0.01, 'Start',cInd);
I am using RootSIFT to extract the features of each image. This produces a vector of 1x128 for each image.
Now I have 45 images maximum for each writer. So after feature extraction and everything the size of my model_feats is 45 x 128.
According to the help file for data arrangement for X is:
The rows of X correspond to observations, and columns correspond to
variables.
The problem I have is when I run the above function I am told that:
"X must have more rows than columns."
I have a total of 45 images for each writer. How will I be able to get this function to run? This is a strange limitation for such a function, I mean even if I am able to get 100 images for each writer it will not work.
I will appreciate any workaround to this.
P.S. I've tried the same with VL_Feat's vl_gmm and it works without any problems but I need this to work in Matlab not VL_FEAT.
With SIFT you usually don't compute the feature for the whole image, but literally hundreds of keypoints for each image. Then you won't have this problem anymore.
Next step then probably is a “bag of visual words” mapping of each image.
I am attempting to quantize a 16 bit .wav file to a lower bit rate using Matlab. I've opened the file using wavread() but I am unsure of how to proceed from here. I know that somehow I need to "round" each sample value to (for example) a 7 bit number. Here's the code that's reading the file:
[file,rate,bits] = wavread('smb.wav');
file is a 1 column matrix containing the values of each sample. I can loop through each item in that matrix like so:
for i=1 : length(file)
% not sure what to put here..
end
Could you point me in the right direction to quantize the data?
If you have int16 data, varying from -32768 to +32767, it can be as simple as
new_data = int8(old_data./2^8);
That won't even require a for loop.
For scaled doubles it would be
new_data = int8(old_data.*2^7);
The wavread documentation suggests that you might even be able retrieve the data in that format to begin with:
[file,rate,bits] = wavread('smb.wav','int8');
EDIT: Changing the bit rate:
After rereading the question, I realize that you also mentioned a lower bit rate which implies reducing the sample rate, not the quantization of the data. If that is the case, you should look at the documentation for downsample, decimate, and/or resample. They are all built in MATLAB functions that change the bit rate.
downsample(file,2)
would half the bit rate, for example.
I have an image shot with an x-ray for which I want to test different segmentation algorithm (like the ones found at http://www.academia.edu/913222/segmentation_techniques)
How can I ignore the background in the calculation, i.e. how can I ignore anything that has a gray value of under 50,000 (for a 16 bit image)?
the code I'm using right now is:
clc;
clear;
[fn,pn]=uigetfile({'*.TIF','Image files'}, 'Select an image');
x = imread(fullfile(pn,fn));
T=graythresh(x);
y=im2bw(x,T);
imshow(y);
but I also want to test different segmentation techniques.
I am trying to model the future implementation of a software in order to find the best course of action and this software will ignore the "background" (I already have a succesful implementation of the otsu algorithm.
Thanks for your wisdom =).
If you want to use Otsu only on the pixel values above 50000, you can simply write
T = graythresh(x(x>50000));
I have a MATLAB variable that is a 3x6 cell array. One of the columns of the cell array holds at most 150-200 small RGB images, like 16x20 pixel size (again, at most). The rest of the columns are:
an equal number of labels that are strings of a 3 or 4 characters,
an image mask, which is about 350x200
3 integers
For some reason saving this object is taking a very long time, or at least for the size of the object. It has already been 10 minutes(which isn't too bad, but I plan on expanding the size of the object to hold several thousand of those small images) and MATLAB doesn't seem to be making any progress. In fact, when I open the containing directory of the variable, its size is cycling between 0 bytes to about 120kB. (i.e. it will increase to 120 in steps of 30 or 40 kB, then restart).
Is this normal behavior? Do MATLAB variables always take so long to save? What's going on here?
Mistake: I'm saving AllData, not my SVM variable. AllData has the same data as the SVM keeper, less the actual SVM itself and one integer.
What particular points of the code would be helpful to show for solving this? The code itself is a few hundred lines and broken up in several functions. What would be important to consider to troubleshoot this? When the variable is created? when it's saved? The way I create the smaller images?
Hate to be the noob who takes a picture of their desktop. but the machine I'm working has problems taking screenshots. Anyway, here it is
Alldata/curdata are just subsets of the 3x7 array... actually it's a 3x8, but the last is just an int.
Interesting side point: I interrupted the saving process and the variable seemed to save just fine. I trained a new svm on the saved data and it works just fine. I'd like to not do that in the future though.
Using whos:
Name Size Bytes Class Attributes
AllData 3x6 473300 cell
Image 240x352x3 253440 uint8
RESTOREDEFAULTPATH_EXECUTED 1x1 1 logical
SVMKeeper 3x8 2355638 cell
ans 3x6 892410 cell
curData 3x6 473300 cell
dirpath 1x67 134 char
im 240x352x3 1013760 single
s 1x1 892586 struct
Updates:
1.Does this always happen, or did you only do it once?
-It always happens
2.Does it take the same time when you save it to a different (local) drive?
-I will investigate this more when I get back to that computer
3.How long does it take to save a 500kb matrix to that folder?
-Almost instantaneous
4.And as asked above, what is the function call that you use?
-Code added below
(Image is a rgb image)
MaskedImage(:,:,1)=Image(:,:,1).*Mask;
MaskedImage(:,:,2)=Image(:,:,2).*Mask;
MaskedImage(:,:,3)=Image(:,:,3).*Mask;
MaskedImage=im2single(MaskedImage);
....
(I use some method to create a bounding box around my 16x20 image)
(this is in a loop of that occurs about 100-200 times)
Misfire=input('is this a misfire?','s');
if (strcmpi(Misfire,'yes'))
curImageReal=MaskedImage(j:j+Ybound,i:i+Xbound,:);
Training{curTrainingIndex}=curImageReal; %Training is a cell array of images
Labels{curTrainingIndex}='ncr';
curTrainingIndex=curTrainingIndex+1;
end
(the loop ends)...
SaveAndUpdate=input('Would you like to save this data?(say yes,definitely)','s');
undecided=1;
while(undecided)
if(strcmpi(SaveAndUpdate,'yes,definitely'))
AllData{curSVM,4}=Training;
AllData{curSVM,5}=Labels;
save(strcat(dirpath,'/',TrainingName),'AllData'); <---STUCK HERE
undecided=0;
else
DontSave=input('Im not going to save. Say YESNOSAVE to NOT SAVE','s')
if(strcmpi(DontSave,'yesnosave'))
undecided=0;
else
SaveAndUpdate=input('So... save? (say yes,definitely)','s');
end
end
end
It is a bit unclear if you are doing some custom file saving or not. If it is the first, I'm guessing that you have a really slow save loop going on, maybe some hardware issues. Try to save the data using MATLAB's save function:
tic
save('test.mat', 'AllData')
toc
if that works fine try to work your way from there e.g. saving one element at a time etc.
You can profile your code by using the profiler, open it with the command profile viewer and then type in the code, script or function that you want to profile in the input text field.
This isn't a great answer, but it seems that the problem was that I was saving the version of my image after I had converted it to a single. I don't know why this would cause such a dramatic slowdown (after removing this line of code it worked instantly) so if someone could edit my answer to shed more light on the situation, that would be appreciated.
Do we have functions in OpenCV or in MATLAB to convert a 24 bit RGB image to 16 bit gray image. I tried CvConvertColor but it is of no use here.
(I can convert to grayscale using cvtColor(src, bwsrc, CV_RGB2GRAY), more help needed, but I want to make it 16 bit from 32 bit.)
I beleive there is the rgb2gray operator in matlab.
Here is a link to where you can read up on it from mathworks site:
http://www.mathworks.com/help/toolbox/images/ref/rgb2gray.html
This even tells you how to read in the image. Most of the code you should need is there!!!
I = imread('board.tif');
J = rgb2gray(I);
figure, imshow(I), figure, imshow(J);
Have you tried OpenCV's cvtcolor? I'm not sure which opencv version you are using but CvConvertColor no longer exists, you should probably set up the latest version.
cvtcolor:
http://docs.opencv.org/modules/imgproc/doc/miscellaneous_transformations.html#cvtcolor
cvtColor itself has no further arguments, it is smart enough to check the bitness of source and destiny matrix. Opencv matrix objects, Mat objects, have a custom opencv type that holds their bitness, number of color channels and primitive type (details: http://docs.opencv.org/modules/core/doc/basic_structures.html#datatype ).
If you want to make sure if the resulting matrix is 16 bit, you can check the Mat type. If the matrixes are not in the bitness you require, opencv has other converter for that: http://docs.opencv.org/modules/core/doc/basic_structures.html?highlight=convert#mat-convertto