我怎么能把白色背景从这张照片吗?

17日视图(30天)
我从事一个项目,我需要删除从类似的图像以堆栈随机在100 x 100嗯矩阵。
谢谢你!
2的评论
Riddhiben Joshi
Riddhiben Joshi 2021年9月29日
你好,谢谢你的回应,通过消除作物白色背景部分和我的意思是只有蓝色部分。
和栈我并说地方相邻2 d,这样我可以控制他们之间的距离。我有7个不同的图像,我想堆栈随机。
我希望这可以帮助!

登录置评。

接受的答案

焉耆刘
焉耆刘 2021年9月26日
先生,可以消除背景,和做一些附加功能,比如
clc;
清晰的所有;
关闭所有;
我= imread (“https://ww2.mathworks.cn/matlabcentral/answers/uploaded_files/741089/20um.jpeg”);
im2 = rgb2hsv (im);
bw = im2bw (im2 (:,: 2), 0.5);
bw = imfill (bw,“黑洞”);
我=我。* uint8(猫(3 bw bw, bw));
%添加一些图片
我= imadd (im, im);
图;imshow (im);
2的评论

登录置评。

答案(1)

图像分析
图像分析 2021年9月29日
试试这个:
%演示图像分析。
clc;%清除命令窗口。
关闭所有;%关闭所有数据(除了imtool。)
clearvars;
工作空间;%确定工作区面板显示。
格式长g;
格式紧凑的;
字形大小= 16;
流(运行% s的开始。m…\ n”,mfilename);
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
%读入图像。这是一个可怕的形象。从不使用JPG格式的图像分析。使用PNG、TIFF或BMP。
文件夹= [];
baseFileName =“20 um.jpeg”;
fullFileName = fullfile(文件夹,baseFileName);
%检查文件是否存在。
如果~存在(fullFileName“文件”)
%的文件不存在,没有找到它在该文件夹。
%检查整个搜索路径(其他文件夹)去掉文件的文件夹。
fullFileNameOnSearchPath = baseFileName;%没有路径。
如果~存在(fullFileNameOnSearchPath“文件”)
%仍然没有找到它。提醒用户。
errorMessage = sprintf (的错误:% s在搜索路径的文件夹不存在。,fullFileName);
uiwait (warndlg (errorMessage));
返回;
结束
结束
rgbImage = imread (fullFileName);
(行、列,numberOfColorChannels) =大小(rgbImage)
%显示图像。
次要情节(2 2 1);
imshow (rgbImage []);
轴(“上”,“图像”);
惠普= impixelinfo ();%设置状态栏看到当你鼠标值图像。
标题= sprintf (的原始RGB图像:“% s”\ n % d % d列的行baseFileName,行、列);
标题(标题,“字形大小”字形大小,“翻译”,“没有”);
drawnow;
惠普= impixelinfo ();%设置状态栏看到当你鼠标值图像。
%设置图属性:
%全屏放大图。
hFig1 = gcf;
hFig1。单位=“归一化”;
hFig1。WindowState =“最大化”;
%去掉工具栏和下拉菜单的图。
%设置(gcf“工具栏”,“没有”,“菜单”,“没有一个”);
%的标题栏提供一个名称。
hFig1。Name =的演示图像分析师”;
%二进制图像。
grayImage = rgb2gray (rgbImage);
binaryImage = ~ imbinarize (grayImage“全球”);
%去除帧在外面。
binaryImage = imclearborder (binaryImage);
%填补
binaryImage = imfill (binaryImage,“黑洞”);
次要情节(2,2,2);
imshow (binaryImage);
%的边界框。
道具= regionprops (binaryImage,的边界框(“大小));
%作物图像。
croppedImage = imcrop (rgbImage props.BoundingBox);
binaryImage = imcrop (binaryImage props.BoundingBox);
%掩模图像使用bsxfun()函数将每个通道单独的面具。适用于灰度以及RGB彩色图像。
croppedImage = bsxfun (@times croppedImage铸造(binaryImage,“喜欢”croppedImage));
%显示图像。
次要情节(2、2、3);
imshow (croppedImage []);
轴(“上”,“图像”);
惠普= impixelinfo ();%设置状态栏看到当你鼠标值图像。
标题(“裁剪图像”,“字形大小”字形大小,“翻译”,“没有”);
drawnow;
对话框(“干!”);

下载188bet金宝搏

社区寻宝

找到宝藏在MATLAB中央,发现社区如何帮助你!

开始狩猎!