Romeo8627
Newbie level 3
Hi,
Here is the objective of what I am trying to do:
I have two images
Image 1: (3500x3000 pixels)
Image 2: (1250x1050 pixels)
I convert the pixel values into binary. Then, I replace the LSB of Image1 with data bits (each bit) from Image2.
Here is the problem:
After reshaping Image1 to row matrix, using dec2bin gives a OUT OF MEMORY error.
So I try to use BLKPROC and BLOCKPROC. They both work dor the dct2 but not for my function. Please help!!
NOTE: While trying to learn blkproc, I am using a very small matrix A with 12 elements.
(I am quite new to Matlab and programming in general. May take me a little more time than others to understand the concepts. Simple language will be very much appreciated.)
Here is my code:
%%%%%% Main Program %%%%%%
%Sample matrix (will be replaced by image data later)
A = uint8(1:12);
% fun = @bin2_img; % Didn't work!! Script is below
% fun= @dct2; % Works!!
fun = @(x) dec2bin(x); % Didn't work
% I want to process the matrix in blocks of 1x3
bin_i = blockproc(A,[1 3], fun);
%%%%%% bin2_img %%%%%%
function y = bin2_img(img_n)
y = dec2bin(img_n);
I have gone through the documentation of the commands. However, I still don't get the internal working of the blkproc and blockproc commands.
Is the whole image passed first and then broken into blocks or is it first broken down and sent passed to the required function?
Thank you very much! All help is appreciated.
Here is the objective of what I am trying to do:
I have two images
Image 1: (3500x3000 pixels)
Image 2: (1250x1050 pixels)
I convert the pixel values into binary. Then, I replace the LSB of Image1 with data bits (each bit) from Image2.
Here is the problem:
After reshaping Image1 to row matrix, using dec2bin gives a OUT OF MEMORY error.
So I try to use BLKPROC and BLOCKPROC. They both work dor the dct2 but not for my function. Please help!!
NOTE: While trying to learn blkproc, I am using a very small matrix A with 12 elements.
(I am quite new to Matlab and programming in general. May take me a little more time than others to understand the concepts. Simple language will be very much appreciated.)
Here is my code:
%%%%%% Main Program %%%%%%
%Sample matrix (will be replaced by image data later)
A = uint8(1:12);
% fun = @bin2_img; % Didn't work!! Script is below
% fun= @dct2; % Works!!
fun = @(x) dec2bin(x); % Didn't work
% I want to process the matrix in blocks of 1x3
bin_i = blockproc(A,[1 3], fun);
%%%%%% bin2_img %%%%%%
function y = bin2_img(img_n)
y = dec2bin(img_n);
I have gone through the documentation of the commands. However, I still don't get the internal working of the blkproc and blockproc commands.
Is the whole image passed first and then broken into blocks or is it first broken down and sent passed to the required function?
Thank you very much! All help is appreciated.