UIfigure value changes on a while loop
显示 更早的评论
לק"י
Hello!
I have a time series stack of cell masks of 21 timepoints. each mask has a unique gray scale value of its own.
I need to acquire a single pixel grayscale vlaue by clicking on the desired cell mask.
My strategy is to have two figures open at the same time.
The first figure will present the image of a single time sequence and after a pixel will be chosen it's grayscale value will be saved.
The second figure will present a loop of the time series to allow me for easy identification of the desired cell. I will only see it no interactions made with this loop figure.
This figure is running with a while loop, that will end only when I click and UIfigure (b) of a button, so the condition is when b.Value==0.
When I run the code, I awkwardly get an error when enetring the third while loop.
The code:
filename='17.07.2024 aHER2 carrier W.T cd45low+cd4+lstrckr001 cellpose stack.tif';
info = imfinfo(filename);
numberOfImages = length(info);
j=1;
for i= 1:numberOfImages
crntimg=imread(filename, i);
figure (1)
imshow (crntimg,[]);
impixelinfo
fig = uifigure;
b = uibutton(fig,"state", "Text","Press to end", "IconAlignment","top", ...
"Position",[100 100 50 50]);
while b.Value == 0
k=1
crntimgloop=imread(filename, j);
imshow (crntimgloop,[]);
if j<21
j=j+1;
else
j=1;
end
j
end
end
The error output:
j =
3
Invalid or deleted object.
Error in matlab.ui.control.internal.model.AbstractBinaryComponent/get.Value (line 95)
value = obj.PrivateValue;
Error in Cell_mask_identification_over_time (line 13)
while b.Value == 0
I tried to upload the mask's time series file, but it was too large.
Thanks,
Amit.
1 个评论
Walter Roberson
2024-7-26
It is better to be more specific about the graphics operations
filename='17.07.2024 aHER2 carrier W.T cd45low+cd4+lstrckr001 cellpose stack.tif';
info = imfinfo(filename);
numberOfImages = length(info);
fig1 = figure(1);
ax1 = axes(fig1);
fig = uifigure();
b = uibutton(fig,"state", "Text","Press to end", "IconAlignment","top", ...
"Position",[100 100 50 50]);
j=1;
for i = 1:numberOfImages
crntimg=imread(filename, i);
imshow(ax1, crntimg,[]);
impixelinfo(ax1);
b.Value = 0;
while b.Value == 0
k=1
crntimgloop=imread(filename, j);
imshow(ax1, crntimgloop, []);
if j<21
j=j+1;
else
j=1;
end
j
end
end
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Image Arithmetic 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
