how can i color the particular block of the image?

조회 수: 1 (최근 30일)
pammy
pammy 2013년 5월 5일
m working on gray scale images.. i've extracted a particular block from the code for the above is :
blockNumber = 1;
blockrows =2; blockcols = 2;
[blockcol, blockrow] = ind2sub( [blockcols, blockrows], blockNumber);
colstart = (blockcol-1) * blockSizeC + 1;
rowstart = (blockrow - 1) * blockSizeR + 1;
oneBlock1 = grayImage(rowstart : rowstart + blockSizeR - 1, colstart : colstart + blockSizeC - 1);
imshow(oneBlock);
i want to color the above block..how can i do so????
grayImage(rowstart : rowstart + blockSizeR - 1, colstart : colstart + blockSizeC - 1)=0;
the above code color the block with black but it distorts the intensity values.
plz help me to do so..

채택된 답변

Iman Ansari
Iman Ansari 2013년 5월 5일
Hi.
clear
grayImage=imread('cameraman.tif');
blockNumber = 34;
blockSizeC=32;
blockSizeR=32;
blockrows =8; blockcols = 8;
[blockrow, blockcol] = ind2sub( [blockcols, blockrows], blockNumber);
colstart = (blockcol-1) * blockSizeC + 1;
rowstart = (blockrow - 1) * blockSizeR + 1;
oneBlock = grayImage(rowstart : rowstart + blockSizeR - 1, colstart : colstart + blockSizeC - 1);
New=cat(3,grayImage,grayImage,grayImage);
New(rowstart : rowstart + blockSizeR - 1, colstart : colstart + blockSizeC - 1,[1 3])=0;
imshow(New);
  댓글 수: 4
Iman Ansari
Iman Ansari 2013년 5월 6일
I changed it to color Image with:
R=grayImage;
G=grayImage;
B=grayImage;
because R,G and B value are the same, so your output image looks gray level image. R and B components in your became 0, your block seems green. Your grayImage didn't change and in color image (New) the green component is the same as grayImage:
New(:,:,2)==grayImage
pammy
pammy 2013년 5월 7일
thank you so much

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Iterator Subsystems에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by