필터 지우기
필터 지우기

i need to add an image as background?

조회 수: 2 (최근 30일)
marc kahwaji
marc kahwaji 2014년 8월 4일
댓글: marc kahwaji 2014년 8월 12일
here is my code
close all; clear all;
P = @(x,y,c,w,a) a.*exp(-((x-repmat(c(1),size(x,1),size(x,2))).^2 + (y-repmat(c(2),size(y,1),size(y,2))).^2)./w); A=[6 8 10]; W = 1; % Width (constant here, can vary as a vector if you like) C = [[18 15 5];[10 10 10]]; % Peak centers x = linspace(0,20,150); % Define ‘x’ vector
[X,Y] = meshgrid(x); pks = zeros(size(X)); % Preallocate ‘pks’ for k1 = 1:size(C,2) % Loop through ‘C’ (centers) vector pks = pks + P(X,Y,C(:,k1),W,A(k1)) ; end
A=meshz(X,Y,pks); view(2);
grid on;
colorbar
i have this code and i need to add an image as a background how can i do it?
  댓글 수: 3
marc kahwaji
marc kahwaji 2014년 8월 7일
find attach the image that i need to put as background

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

채택된 답변

Image Analyst
Image Analyst 2014년 8월 5일
Try this:
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
imtool close all; % Close all imtool figures if you have the Image Processing Toolbox.
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 13;
close all;
clear all;
P = @(x,y,c,w,a) a.*exp(-((x-repmat(c(1),size(x,1),size(x,2))).^2 + (y-repmat(c(2),size(y,1),size(y,2))).^2)./w);
A=[6 8 10];
W = 1; % Width (constant here, can vary as a vector if you like)
C = [[18 15 5];[10 10 10]]; % Peak centers
x = linspace(0,20,150); % Define ‘x’ vector
[X,Y] = meshgrid(x);
pks = zeros(size(X)); % Preallocate ‘pks’
for k1 = 1:size(C,2) % Loop through ‘C’ (centers) vector
pks = pks + P(X,Y,C(:,k1),W,A(k1)) ;
end
subplot(1,3,1);
imshow(pks);
grid on;
colorbar
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
% Read in background image.
backgroundImage = imread('cameraman.tif');
% Make same size as pks.
backgroundImage = double(imresize(backgroundImage, size(pks)));
% Normalize
backgroundImage = backgroundImage * max(pks(:)) / max(backgroundImage(:));
subplot(1,3,2);
imshow(backgroundImage, []);
axis on;
compositeImage = backgroundImage; % Initialize.
% Get location of circles.
circleLocations = pks > 0.001;
% Now add circles.
compositeImage(circleLocations) = pks(circleLocations);
subplot(1,3, 3);
imshow(compositeImage, []);
axis on;
  댓글 수: 13
Image Analyst
Image Analyst 2014년 8월 12일
numel() is the number of pixels in the image. weight says how much wieght to apply to one image. The other line just does the weighted sum. It just says how much of one image shows in comparison to the other image. Not sure how to describe weighted sum. I thought everyone knew what it was. Perhaps you can Google it.
marc kahwaji
marc kahwaji 2014년 8월 12일
okey thanks for your help !!

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

추가 답변 (0개)

카테고리

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