フィルターのクリア

I have a code to merge Region of interest (ROI) and Non-ROI of an image but I am getting error. please help.

3 ビュー (過去 30 日間)
Sir, my code to merge ROI and Non-ROI is given below. However it is giving an error.
if true
% %%example code for Pramod Bhat from Jonas:
% get file to be displayed
[FileName,PathName] = uigetfile('*.*','Select the Image');
[img, map] = imread(fullfile(PathName,FileName));
% display image and select region
f = figure;
imshow(img, map);
roi = imfreehand(gca);
wait(roi);
% get the mask
mask = roi.createMask;
% extract the boundarybox of the ROI
S = regionprops(mask,'Boundingbox');
b = floor(S(1).BoundingBox);
% crop the interesting part of the image (bounding box)
imgcut = img(b(2):b(2)+b(4), b(1):b(1)+b(3));
maskcut = double(mask(b(2):b(2)+b(4), b(1):b(1)+b(3)));
% finally, save the image
[FileName,PathName] = uiputfile('*.png','Save the Image As');
imgcutrgb = ind2rgb(imgcut,map);
% note: only what is inside of your ROI will be displayed,
% the rest is set to be transparent:
imwrite(imgcutrgb,fullfile(PathName,FileName),'Alpha', maskcut);
end
The error is as below
Index exceeds matrix dimensions.
Error in ind2rgb (line 26) r = zeros(size(a)); r(:) = cm(a,1);
Error in mergeROI_NonROI (line 20) imgcutrgb = ind2rgb(imgcut,map); I am enclosing the input image herewith. Kindly help. Thanks and Regards Debarpita Chaudhuri.
  1 件のコメント
Debarpita Chaudhuri
Debarpita Chaudhuri 2016 年 10 月 27 日
Dear Sir, I am using a new code to merge the ROI and Non_ROI by using imfuse function. But the images are of different sizes due to which I am not getting any satisfactory result as an output. The code is given below...
Kindly help me Sir. I am attaching the images herewith. Thanks and regards Debarpita Chaudhuri.
if true
% A = imread('wcompressed_grayimg.bmp');
B = imread('ROI.bmp');
C = imfuse(A,B,'blend', 'Scaling', 'joint');
imwrite(C, 'merged_tumor_img.bmp');
imshow(C);
end

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

回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by