フィルターのクリア

How do I change the background on an image?

1 回表示 (過去 30 日間)
Jose
Jose 2013 年 4 月 8 日
Given an image filename and a background image file name, how would I write a function that changes the images blue background with the background in the background file. Then write the updated image to a file with 'updated_' appended before the background filename.
So far I have
function new = changeBackground(fn1, background)
pic = imread('fn1. jpg') [r c l] = size(cat); background = imread('background.jpg') [r1 c1 l1] = size(background); red = (:, :, 1); green = (:, :, 2); blue = (:, :,3);
cutout= fn1(fn1~=blue);
new = imwrite(cutout, background); new = imwrite(new, 'updated_background); end
I think I separated and concatenated the images into RGB layers incorrectly, as well as indexed the blue mask incorrectly.
  2 件のコメント
Image Analyst
Image Analyst 2013 年 4 月 8 日
Yeah, that won't work because cutout is a 1D vector, not a 2D mask array. Before I fix it, where did you upload your images to? http://www.mathworks.com/matlabcentral/answers/7924-where-can-i-upload-images-and-files-for-use-on-matlab-answers
Jose
Jose 2013 年 4 月 8 日
編集済み: Image Analyst 2013 年 4 月 9 日

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

回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by