how can i solve the reshape error appearing in my code?

1 view (last 30 days)
The code posted below is for embedding and extracting of a .emb and .ext file generated in an hdl code. I am getting a reshape error while running the extraction code... Please solve
clc;
clear all;
close all;
M = 140;
N = 140;
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
[FileName,PathName] = uigetfile('*.list','Select Original Image');
fileID = fopen([PathName,FileName],'r');
A = fscanf(fileID, '%x');
fclose(fileID);
original_img = reshape(A,N,M);
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
[FileName,PathName] = uigetfile('*.emb','Select Embedded Image');
fileID = fopen([PathName,FileName],'r');
A = fscanf(fileID, '%x');
fclose(fileID);
Extract_img = reshape(A,N,M);
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
subplot(1,2,1);
imshow(original_img',[]);
title('Original Image');
subplot(1,2,2);
imshow(Extract_img',[]);
title('Embedded Image');
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
M = 45;
N = 45;
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
[FileName,PathName] = uigetfile('*.ext','Select Extracted watermark Image');
fileID = fopen([PathName,FileName],'r');
A = fscanf(fileID, '%x');
fclose(fileID);
Extract_img = reshape(A,M,N);
figure;
subplot(1,2,1);
imshow(Extract_img',[]);
title('Extracted Watermark Image');

Accepted Answer

Tim McBrayer
Tim McBrayer on 13 Jul 2016
I'm not sure what you are trying to do with HDL Coder here, but there is basically no code in your example that is supported by HDL Coder. Specifically, the following function calls are not supported for HDL code generation:
  • fopen
  • fclose
  • fscanf
  • uigetfile
  • figure
  • subplot
  • imshow
  • title
  2 Comments
PRIYANKA SHIRODKAR
PRIYANKA SHIRODKAR on 14 Jul 2016
This is my final year project of steganography. I wished to implement the project using an HDL code as well as the MATLAB code. The HDL code gives the simulation results for embedding and extraction of text from an image. But the MATLAB code written above performs only embedding and not extraction. During the extraction code it displays the reshape error
Tim McBrayer
Tim McBrayer on 20 Jul 2016
You will need to figure out what is your driver code for your implementation. This is your testbench for HDL code generation, and can contain any code. This is where you read and write files, display plots, and so forth.
The actual implementation of your steganography engine can be converted to HDL if it is modeled appropriately. You will want to accept your image a pixel at a time and perform the embedding and/or extraction on the pixel stream.

Sign in to comment.

More Answers (0)

Tags

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!