フィルターのクリア

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 件のコメント
Star Strider
Star Strider 2014 年 8 月 5 日
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 Center および File ExchangeExplore 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