【交互式阈值二进制图像】采用彩色或单色图像通过交互/手动方式阈值单色图像或彩色图像的单个色带研究(Matlab代码实现)

本文主要是介绍【交互式阈值二进制图像】采用彩色或单色图像通过交互/手动方式阈值单色图像或彩色图像的单个色带研究(Matlab代码实现),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

 💥💥💞💞欢迎来到本博客❤️❤️💥💥

🏆博主优势:🌞🌞🌞博客内容尽量做到思维缜密,逻辑清晰,为了方便读者。

⛳️座右铭:行百里者,半于九十。

📋📋📋本文目录如下:🎁🎁🎁

目录

💥1 概述

📚2 运行结果

🎉3 参考文献

🌈4 Matlab代码实现


💥1 概述

【交互式阈值二进制图像】采用彩色或单色图像通过交互/手动方式阈值单色图像或彩色图像的单个色带

本文介绍了一种交互式阈值二进制图像的方法。该方法可以应用于彩色或单色图像,并且允许用户通过滑块的方式以交互/手动的方式设置图像的阈值范围。

阈值图像是一种二进制图像,可以用作其他图像的遮罩图像。在阈值范围内的像素将在中间图像中显示为二进制图像(黑/白),而原始图像的像素将在左侧图像中显示为遮罩(灰度或彩色)。用户可以通过设置最大和最小阈值来调整阈值范围,从而实现对图像的二值化处理。

该方法的输入包括要开始的低阈值和高阈值,以及图像文件名或图像矩阵。可以处理的图像类型包括整数类型(如uint8、uint16等)和浮点类型(如单精度、双精度)。

该方法的输出包括阈值范围和用于选择阈值的最后一个色带。用户可以根据自己的需求选择合适的阈值范围,并通过调整滑块来实现图像的二值化处理。

通过使用交互式阈值二进制图像的方法,用户可以更加灵活地处理彩色或单色图像,并根据需要调整阈值范围,从而得到满足自己需求的二值化图像。该方法具有简单、直观的操作界面,适用于各种图像处理应用场景。

📚2 运行结果

部分代码:

% Read in a standard MATLAB gray scale demo image.
folder = fileparts(which('cameraman.tif')); % Determine where demo folder is (works with all versions).
baseFileName = 'cameraman.tif';
fullFileName = fullfile(folder, baseFileName);
if ~exist(fullFileName, 'file')% File doesn't exist.  Try it without the folder.% It might be able to find it in a folder off the search path.fullFileName = baseFileName;if ~exist(fullFileName, 'file')% Can't find it off the search path either.errorMessage = sprintf('Error: cannot find demo image %s', baseFileName);uiwait(msgbox(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, 3, 1);
imshow(grayImage, []);
axis off;
title('Original Grayscale Image', 'FontSize', fontSize);
% Set up figure properties.
set(gcf, 'Name', 'Thresholding Demo by ImageAnalyst', 'NumberTitle', 'off') 
set(gcf, 'Toolbar', 'none', 'Menu', 'none');
set(gcf, 'Position', get(0,'Screensize')); % Enlarge figure to full screen.message = sprintf('Thresholding demo by ImageAnalyst.\n\nDo you want to use an integer image or a floating point image?');
button = questdlg(message, 'Image Type?', 'Integer', 'Floating Point', 'Cancel', 'Integer');
drawnow;	% Refresh screen to get rid of dialog box remnants.
if strcmpi(button, 'Cancel')close(gcf);	% Get rid of window.return;
end
if strcmpi(button, 'Floating Point')% Convert to double in the range -5000 to + 15000% Get input min and max.minGL = double(min(grayImage(:)));maxGL = double(max(grayImage(:)));% Scale the imageimageToThreshold = 20000 * mat2gray(grayImage) - 5000;% Verify themminDblGL = min(imageToThreshold(:));maxDblGL = max(imageToThreshold(:));fprintf('Before scaling, min gray level = %.1f, max gray level = %.1f\nAfter scaling,  min gray level = %.1f, max gray level = %.1f\n', ...minGL, maxGL, minDblGL, maxDblGL);startingLowThreshold = -800;startingHighThreshold = 10400;% Get the histogram[pixelCount, grayLevels] = hist(imageToThreshold(:), 300);subplot(2, 3, 2); bar(grayLevels, pixelCount, 'BarWidth', 1, 'FaceColor', 'b');title('Histogram of Original Double Image', 'FontSize', fontSize);xlim([minDblGL, maxDblGL]); % Scale x axis manually.

% Read in a standard MATLAB gray scale demo image.
folder = fileparts(which('cameraman.tif')); % Determine where demo folder is (works with all versions).
baseFileName = 'cameraman.tif';
fullFileName = fullfile(folder, baseFileName);
if ~exist(fullFileName, 'file')
    % File doesn't exist.  Try it without the folder.
    % It might be able to find it in a folder off the search path.
    fullFileName = baseFileName;
    if ~exist(fullFileName, 'file')
        % Can't find it off the search path either.
        errorMessage = sprintf('Error: cannot find demo image %s', baseFileName);
        uiwait(msgbox(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, 3, 1);
imshow(grayImage, []);
axis off;
title('Original Grayscale Image', 'FontSize', fontSize);
% Set up figure properties.
set(gcf, 'Name', 'Thresholding Demo by ImageAnalyst', 'NumberTitle', 'off') 
set(gcf, 'Toolbar', 'none', 'Menu', 'none');
set(gcf, 'Position', get(0,'Screensize')); % Enlarge figure to full screen.

message = sprintf('Thresholding demo by ImageAnalyst.\n\nDo you want to use an integer image or a floating point image?');
button = questdlg(message, 'Image Type?', 'Integer', 'Floating Point', 'Cancel', 'Integer');
drawnow;    % Refresh screen to get rid of dialog box remnants.
if strcmpi(button, 'Cancel')
    close(gcf);    % Get rid of window.
    return;
end
if strcmpi(button, 'Floating Point')
    % Convert to double in the range -5000 to + 15000
    % Get input min and max.
    minGL = double(min(grayImage(:)));
    maxGL = double(max(grayImage(:)));
    % Scale the image
    imageToThreshold = 20000 * mat2gray(grayImage) - 5000;
    % Verify them
    minDblGL = min(imageToThreshold(:));
    maxDblGL = max(imageToThreshold(:));
    fprintf('Before scaling, min gray level = %.1f, max gray level = %.1f\nAfter scaling,  min gray level = %.1f, max gray level = %.1f\n', ...
        minGL, maxGL, minDblGL, maxDblGL);
    startingLowThreshold = -800;
    startingHighThreshold = 10400;
    % Get the histogram
    [pixelCount, grayLevels] = hist(imageToThreshold(:), 300);
    subplot(2, 3, 2); 
    bar(grayLevels, pixelCount, 'BarWidth', 1, 'FaceColor', 'b');
    title('Histogram of Original Double Image', 'FontSize', fontSize);
    xlim([minDblGL, maxDblGL]); % Scale x axis manually.

🎉3 参考文献

文章中一些内容引自网络,会注明出处或引用为参考文献,难免有未尽之处,如有不妥,请随时联系删除。

[1]龙建武,申铉京,陈海鹏.基于图像区域的交互式文本图像阈值分割算法[J].计算机研究与发展, 2012, 49(7):12.DOI:CNKI:SUN:JFYZ.0.2012-07-005.

[2]龙建武申铉京陈海鹏.基于图像区域的交互式文本图像阈值分割算法[J].计算机研究与发展, 2012, 49(7):1420-1431.

[3]兰红.多阈值优化的交互式医学图像分割方法[J].计算机科学, 2013, 40(9):4.DOI:10.3969/j.issn.1002-137X.2013.09.066.

🌈4 Matlab代码实现

这篇关于【交互式阈值二进制图像】采用彩色或单色图像通过交互/手动方式阈值单色图像或彩色图像的单个色带研究(Matlab代码实现)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/180778

相关文章

基于Redisson实现分布式系统下的接口限流

《基于Redisson实现分布式系统下的接口限流》在高并发场景下,接口限流是保障系统稳定性的重要手段,本文将介绍利用Redisson结合Redis实现分布式环境下的接口限流,具有一定的参考价值,感兴趣... 目录分布式限流的核心挑战基于 Redisson 的分布式限流设计思路实现步骤引入依赖定义限流注解实现

Python跨文件实例化、跨文件调用及导入库示例代码

《Python跨文件实例化、跨文件调用及导入库示例代码》在Python开发过程中,经常会遇到需要在一个工程中调用另一个工程的Python文件的情况,:本文主要介绍Python跨文件实例化、跨文件调... 目录1. 核心对比表格(完整汇总)1.1 自定义模块跨文件调用汇总表1.2 第三方库使用汇总表1.3 导

SpringBoot实现虚拟线程的方案

《SpringBoot实现虚拟线程的方案》Java19引入虚拟线程,本文就来介绍一下SpringBoot实现虚拟线程的方案,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,... 目录什么是虚拟线程虚拟线程和普通线程的区别SpringBoot使用虚拟线程配置@Async性能对比H

基于Python实现进阶版PDF合并/拆分工具

《基于Python实现进阶版PDF合并/拆分工具》在数字化时代,PDF文件已成为日常工作和学习中不可或缺的一部分,本文将详细介绍一款简单易用的PDF工具,帮助用户轻松完成PDF文件的合并与拆分操作... 目录工具概述环境准备界面说明合并PDF文件拆分PDF文件高级技巧常见问题完整源代码总结在数字化时代,PD

Linux之UDP和TCP报头管理方式

《Linux之UDP和TCP报头管理方式》文章系统讲解了传输层协议UDP与TCP的核心区别:UDP无连接、不可靠,适合实时传输(如视频),通过端口号标识应用;TCP有连接、可靠,通过确认应答、序号、窗... 目录一、关于端口号1.1 端口号的理解1.2 端口号范围的划分1.3 认识知名端口号1.4 一个进程

Python实现Word转PDF全攻略(从入门到实战)

《Python实现Word转PDF全攻略(从入门到实战)》在数字化办公场景中,Word文档的跨平台兼容性始终是个难题,而PDF格式凭借所见即所得的特性,已成为文档分发和归档的标准格式,下面小编就来和大... 目录一、为什么需要python处理Word转PDF?二、主流转换方案对比三、五套实战方案详解方案1:

SpringBoot集成EasyExcel实现百万级别的数据导入导出实践指南

《SpringBoot集成EasyExcel实现百万级别的数据导入导出实践指南》本文将基于开源项目springboot-easyexcel-batch进行解析与扩展,手把手教大家如何在SpringBo... 目录项目结构概览核心依赖百万级导出实战场景核心代码效果百万级导入实战场景监听器和Service(核心

C# async await 异步编程实现机制详解

《C#asyncawait异步编程实现机制详解》async/await是C#5.0引入的语法糖,它基于**状态机(StateMachine)**模式实现,将异步方法转换为编译器生成的状态机类,本... 目录一、async/await 异步编程实现机制1.1 核心概念1.2 编译器转换过程1.3 关键组件解析

基于Python Playwright进行前端性能测试的脚本实现

《基于PythonPlaywright进行前端性能测试的脚本实现》在当今Web应用开发中,性能优化是提升用户体验的关键因素之一,本文将介绍如何使用Playwright构建一个自动化性能测试工具,希望... 目录引言工具概述整体架构核心实现解析1. 浏览器初始化2. 性能数据收集3. 资源分析4. 关键性能指

使用Redis快速实现共享Session登录的详细步骤

《使用Redis快速实现共享Session登录的详细步骤》在Web开发中,Session通常用于存储用户的会话信息,允许用户在多个页面之间保持登录状态,Redis是一个开源的高性能键值数据库,广泛用于... 目录前言实现原理:步骤:使用Redis实现共享Session登录1. 引入Redis依赖2. 配置R