How to remove error "Integers can only be combined with integers of the same class, or scalar doubles."
조회 수: 1 (최근 30일)
이전 댓글 표시
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')
댓글 수: 0
채택된 답변
Image Analyst
2013년 12월 25일
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.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Encryption / Cryptography에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!