필터 지우기
필터 지우기

Generating the edge for a higher intensity pixels and not low intensity pixels.

조회 수: 8 (최근 30일)
Hello Image Processing Committee ---
I have tried several ways to isolate the high intensity blue pixels fromt he low intensity pixels. using bilateral filtering method and an example shown below. I am unable to create a shape around the image provided below. The shape should be around the higher intensity blue pixels and not the low intensity pixels. Plus, if possible to apply Otsu thresholding in such condition?
Thank you for you help.
Best regards,
% Read the image
close all; clear all;
ImageData = imread('Trial.jpg');
Error using imread>get_full_filename
File "Trial.jpg" does not exist.

Error in imread (line 372)
fullname = get_full_filename(filename);
% Convert the image to grayscale
RGBImage = imgaussfilt(ImageData,3);
GrayImage = RGBImage(:,:,3);
% Convert the grayscale image to double precision
ImageDataGray = im2double(GrayImage);
% Define the threshold values for edge detection
lowThreshold = 0.6;
highThreshold = 0.9;
% Apply Canny edge detection
edgeImage = edge(ImageDataGray, 'Canny', [lowThreshold, highThreshold]);
% Display the images in subplots
figure;
% Original Image
subplot(1, 3, 1);
imshow(ImageData);
title('Original Image');
% Grayscale Image
subplot(1, 3, 2);
imshow(ImageDataGray);
title('Grayscale Image');
% Edge Image
subplot(1, 3, 3);
imshow(edgeImage);
title('Edge Detection');
% Find connected components in the edge image
CC = bwconncomp(edgeImage);
numObjects = CC.NumObjects;
% Process each connected component
for k = 1:numObjects
% Extract the k-th object
BW = false(size(edgeImage));
BW(CC.PixelIdxList{k}) = true;
% Calculate the properties of the object using regionprops
P = regionprops(BW, 'Centroid', 'BoundingBox', 'Area', 'Perimeter');
% Filter out faint intensity objects based on area
thresholdArea = 50; % Adjust this value as per your requirement
if P.Area > thresholdArea
% Extract the necessary properties
xCenter = P.Centroid(1);
yCenter = P.Centroid(2);
Area = P.Area;
BoundingBox = P.BoundingBox;
% Plot the boundary and center of the detected object on the image
figure;
imshow(ImageData);
hold on;
rectangle('Position', BoundingBox, 'EdgeColor', 'r', 'LineWidth', 2);
plot(xCenter, yCenter, 'g+', 'MarkerSize', 10, 'LineWidth', 2);
hold off;
end
end
  댓글 수: 1
ProblemSolver
ProblemSolver 2023년 6월 27일
편집: ProblemSolver 2023년 6월 27일
As, it can be seen that the low intensity image is in the background, and a high intensity image is in foreground. I need to draw shape for both the intensities separately.
Thank you for your help.

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

채택된 답변

Image Analyst
Image Analyst 2023년 6월 27일
Not sure what you call low intensity. So if the high intensity mask is all pixels above some threshold, then isn't the low intensity mask just the inverse of that? In other words the whole image except the spot in the middle? And the spot in the middle does not have sharp edges so where the edge of it is, is actually a judgment call. You can get different diameters just by specifying different thresholds. I don't think you need bilateral filteringg or edge detection at all. Why do you think you do? Don't spend time doing unnecessary operations. What are you going do to once you have the high and low intensity masks? That will help me decide what operations other than thresholding that you need to do.
  댓글 수: 5
Image Analyst
Image Analyst 2023년 6월 29일
Using a fixed threshold is best. It's the most reliable, robust, and repeatable. If you're not able to use a fixed threshold, you have to ask yourself why. Do you not have good control over your image capture conditions like lighting and camera settings? If not, try to control them so that the picture is largely the same, like the intensity is the same and only the diameter changes. Then you can use a fixed threshold and get an accurate diameter. If you have to change both the threshold because the settings change and also the object itself changes then you will have noisier results because as I already said you can get different diameters depending on the threshold. So the measured diameter would be changing not only due to the subject/object itself changing but also due to adjustments in the threshold. Try to avoid automatic threshold selection if at all possible and correct your image capture situation instead.
ProblemSolver
ProblemSolver 2023년 6월 29일
편집: ProblemSolver 2023년 6월 29일
@Image Analyst - Yes, I completely understand. Thats the reason before you wrote this answer, I already accepted your answer. I did check the accuracy of my camera of my camera and the light setting, the skewness, sauration of the pixels, etc. to validate if the camera setting can be refined more. However, the camera setting were set and the parallelisim between the CMOS chip and the window was accurate within an uncertainty was within less than 1.045%.
Thank you for the help.

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

추가 답변 (1개)

DGM
DGM 2023년 6월 27일
이동: DGM 2023년 6월 27일
If you're wanting to identify regions by intensity, why are you using edgefinding? Edgefinding is sensitive to gradient, not to intensity.
inpict = imread('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1420743/image.jpeg');
% i'm not sure which areas you're trying to select
% i'm going to select the whitish peak separately from the blue disk
% if the two are to be exclusive sets, then just use boolean ops to combine the two
peakmk = inpict(:,:,1) > 26;
mainmk = inpict(:,:,3) > 103;
imshow(peakmk)
imshow(mainmk)
If you want to reduce those to masks delineating the mask boundary, use bwperim() or bwboundary() on the corresponding mask.
  댓글 수: 3
DGM
DGM 2023년 6월 27일
It's hard to come up with a method that will work for varied images based on a single sample image. We'd need to know how the images can plausibly vary -- both the manner in which they vary and the degree to which they vary.
ProblemSolver
ProblemSolver 2023년 6월 27일
I understand. The pictures plausible changes are as such shown in the these three images. In the first picture you have only the low intensity pixels, then in the next one you have low and high intensity pixels, and finally you have the low-intensity pixels are almost equivalent to the high-intensity pixels.

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

카테고리

Help CenterFile Exchange에서 Image Data Workflows에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by