Image not displaying exactly

1 回表示 (過去 30 日間)
nkumar
nkumar 2013 年 2 月 23 日
I have a image ,divided it to blocks, drawn rectangle and now when i displayes it is not displaying ,plz tell where i made mistake
clc
clear all
I=imread('peppers.png');
I=rgb2gray(I);
[ r c n ]=size(I);
siz = 64;
bs = siz;
Original = I; G = I ;
nob = (r/bs)*(c/bs);
in =0;
kk=0;
for i=1:(r/bs)
for j=1:(c/bs)
myima8(:,:,kk+j)=G((bs*(i-1)+1:bs*(i-1)+bs),(bs*(j-1)+1:bs*(j-1)+bs));
k8((bs*(i-1)+1:bs*(i-1)+bs),(bs*(j-1)+1:bs*(j-1)+bs))=figure,imshow(myima8(:,:,kk+j));rectangle('Position',[3,3,60,60],'EdgeColor','r','LineWidth',2)
end
kk=kk+(r/bs);
end
figure;imshow(k8,[])
kindly assist
  2 件のコメント
Youssef  Khmou
Youssef Khmou 2013 年 2 月 23 日
編集済み: Youssef Khmou 2013 年 2 月 23 日
hi, it keeps displaying figures of blocks , is that your goal, the code is working , what do you mean its not displaying?
it displayed more than 40 images, just in case you want stop it, use ctrl+c
nkumar
nkumar 2013 年 2 月 23 日
but it shows black and white,not original image,i need rectangular boxes over each subblock in final image

サインインしてコメントする。

採用された回答

Youssef  Khmou
Youssef Khmou 2013 年 2 月 23 日
編集済み: Youssef Khmou 2013 年 2 月 23 日
nkumar,
i see now how you want the blocks merged into single output,
try this ,
clc,clear all
I=rgb2gray(im2double(imread('peppers.png')));
[m n]=size(I);
dx=64;
dy=64;
J=I;
for x=1:m
if mod(x,64)==0
J(x,:)=0;
end
end
for y=1:n
if mod(y,64)==0
J(:,y)=0;
end
end
figure, imshow(J);
Waiting for better approach by decomposing I into 48 blocks each of 64² pixels...

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2013 年 2 月 23 日
Your fragment
k8((bs*(i-1)+1:bs*(i-1)+bs),(bs*(j-1)+1:bs*(j-1)+bs))=figure
creates a new figure window and copies the (numeric) handle graphics handle of the figure window into those elements of k8(). That is not going to be what you want to do!
I have no idea what you are expecting your "k8" to represent, but storing numeric figure handles in there is not going to be useful.
  1 件のコメント
nkumar
nkumar 2013 年 2 月 23 日
walter i need as

サインインしてコメントする。

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by