Azzera filtri
Azzera filtri

How to remove error "Integers can only be combined with integers of the same class, or scalar doubles."

3 visualizzazioni (ultimi 30 giorni)
When I'm using typecasting my image quality is affected and I'm not getting desired results. Here is my code:
clc
[file path]=uigetfile('*.*');
img=imread(file);
[r c p]=size(img);
[pl1 pl2 pl3 pl4 pl5 pl6 pl7 pl8]=bitplane_slice(img);
figure;
subplot(3,3,1);imshow(pl1);title('pln 1')
subplot(3,3,2);imshow(pl2);title('pln 2')
subplot(3,3,3);imshow(pl3);title('pln 3')
subplot(3,3,4);imshow(pl4);title('pln 4')
subplot(3,3,5);imshow(pl5);title('pln 5')
subplot(3,3,6);imshow(pl6);title('pln 6')
subplot(3,3,7);imshow(pl7);title('pln 7')
subplot(3,3,8);imshow(pl8);title('pln 8')
sec=imread('ab.png');
new_sec=imresize(sec,[r c]);
stego = new_sec+pl2*2+pl3*4+pl4*8+pl5*16+pl6*32+pl7*64+pl8*128;
figure;
subplot(1,2,1);imshow(new_sec);title('Sec image')
subplot(1,2,2);imshow(uint8(stego));title('Stego image')
[pl1 pl2 pl3 pl4 pl5 pl6 pl7 pl8]=bitplane_slice(stego);
figure;
subplot(3,3,1);imshow(pl1);title('pln 1')
subplot(3,3,2);imshow(pl2);title('pln 2')
subplot(3,3,3);imshow(pl3);title('pln 3')
subplot(3,3,4);imshow(pl4);title('pln 4')
subplot(3,3,5);imshow(pl5);title('pln 5')
subplot(3,3,6);imshow(pl6);title('pln 6')
subplot(3,3,7);imshow(pl7);title('pln 7')
subplot(3,3,8);imshow(pl8);title('pln 8')

Risposta accettata

Image Analyst
Image Analyst il 25 Dic 2013
Because you're essentially adding two images with the least significant bit of one zeroed out, you're most likely going to get overflow which, for a uint8 image, means that you'll clip at 288. Cast everything to double before summing to avoid the error.
  6 Commenti
ROMIL
ROMIL il 26 Dic 2013
Well I can overwrite the existing plane, but still need to merge all the bit planes, can you provide me a better alternative to arithmetic sum?

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by