필터 지우기
필터 지우기

pixel dimension

조회 수: 2 (최근 30일)
parul
parul 2012년 3월 20일
Can someone please tell me how to make the two images of same dimension to fuse it in matlab??One image has 148*114*3 dimension and the other has 148*114 dimension.
  댓글 수: 3
parul
parul 2012년 3월 21일
Fuse the images means that we are taking the infrared image and the brightness component from the rgb image and then using the discrete wavelet frame based fusion method,we are fusing those two images.But the problem is dat these two images dat need to be fused are not of same dimensions.How can i do dat??
Image Analyst
Image Analyst 2012년 3월 21일
But you said they were both 148 by 114 so they ARE of the same lateral dimensions. It's just that one is color and one is grayscale. Perhaps you meant "field of view" rather than "dimension"???

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

채택된 답변

Walter Roberson
Walter Roberson 2012년 3월 21일
Suppose the 148*114 image is named image2. Then
image2_3d = cat(3, image2, image2, image2);
Then image2_3d will be the same dimension as your 148 * 114 * 3 image.
Note: given your description of what you need to do, I think you will find that this does not do anything useful for you, but it will at least give you two images "of the same dimension" that you can use to get to the point of understanding yourself why that isn't what you need.
  댓글 수: 1
parul
parul 2012년 3월 21일
Thanx alot...It was really useful.

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

추가 답변 (2개)

Image Analyst
Image Analyst 2012년 3월 20일
You could average the grayscale image in with each of the color channels (make sure you cast to single or double before doing that though or you'll get clipping), or you could replace one of the color channels. What do you want to do? See this demo code:
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
imtool close all; % Close all imtool figures.
clear; % Erase all existing variables.
workspace; % Make sure the workspace panel is showing.
fontSize = 20;
% Read in a standard MATLAB gray scale demo image.
folder = fullfile(matlabroot, '\toolbox\images\imdemos');
baseFileName = 'cameraman.tif';
fullFileName = fullfile(folder, baseFileName);
% Get the full filename, with path prepended.
fullFileName = fullfile(folder, baseFileName);
if ~exist(fullFileName, 'file')
% Didn't find it there. Check the search path for it.
fullFileName = baseFileName; % No path this time.
if ~exist(fullFileName, 'file')
% Still didn't find it. Alert user.
errorMessage = sprintf('Error: %s does not exist.', fullFileName);
uiwait(warndlg(errorMessage));
return;
end
end
grayImage = imread(fullFileName);
% Get the dimensions of the image.
% numberOfColorBands should be = 1.
[rows columns numberOfColorBands] = size(grayImage);
% Display the original gray scale image.
subplot(2, 2, 1);
imshow(grayImage, []);
title('Original Grayscale Image', 'FontSize', fontSize);
% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
% Give a name to the title bar.
set(gcf,'name','Demo by ImageAnalyst','numbertitle','off')
% Read in a standard MATLAB color demo image.
folder = fullfile(matlabroot, '\toolbox\images\imdemos');
baseFileName = 'peppers.png';
fullFileName = fullfile(folder, baseFileName);
% Get the full filename, with path prepended.
fullFileName = fullfile(folder, baseFileName);
if ~exist(fullFileName, 'file')
% Didn't find it there. Check the search path for it.
fullFileName = baseFileName; % No path this time.
if ~exist(fullFileName, 'file')
% Still didn't find it. Alert user.
errorMessage = sprintf('Error: %s does not exist.', fullFileName);
uiwait(warndlg(errorMessage));
return;
end
end
rgbImage = imread(fullFileName);
% Resize the image to be the same as the gray scale image.
rgbImage = imresize(rgbImage, [rows columns]);
% Get the dimensions of the image. numberOfColorBands should be = 3.
[rows columns numberOfColorBands] = size(rgbImage);
% Display the original color image.
subplot(2, 2, 2);
imshow(rgbImage, []);
title('Original Color Image', 'FontSize', fontSize);
% Extract the individual red, green, and blue color channels.
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
% Method 1: Average the images
redChannel2 = (single(redChannel) + single(grayImage)) / 2;
greenChannel2 = (single(greenChannel) + single(grayImage)) / 2;
blueChannel2 = (single(blueChannel) + single(grayImage)) / 2;
aveRGBImage = cat(3, uint8(redChannel2), uint8(greenChannel2), uint8(blueChannel2));
% Display the new color image.
subplot(2, 2, 3);
imshow(aveRGBImage, []);
title('Averaged Color Image', 'FontSize', fontSize);
% Method 2: replace one channel, say the green.
newRGBImage = cat(3, uint8(redChannel), uint8(grayImage), uint8(blueChannel));
% Display the new color image.
subplot(2, 2, 4);
imshow(newRGBImage, []);
title('Green-replaced Color Image', 'FontSize', fontSize);
  댓글 수: 1
Image Analyst
Image Analyst 2012년 3월 21일
It would have been nice of you to mention "discrete wavelet frame based fusion method" in your initial post. Please ignore all the demo code I gave you above.

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


James morgenstern
James morgenstern 2012년 3월 21일
You need to 'Resample' one or both images to match resolution. Then you need to make them the same size in order to register them. Matlab has demos on image registration.

카테고리

Help CenterFile Exchange에서 Explore and Edit Images with Image Viewer App에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by