2 different imshow() calls send images to same figure?

3 ビュー (過去 30 日間)
Lakshay Sood
Lakshay Sood 2021 年 7 月 8 日
回答済み: yanqi liu 2021 年 9 月 29 日
I'm trying to open 2 separate figures and display a grayscale image in each figure using imshow. However, when I do so, the title of my first image is removed, but not the image itself. Figure(1) is also renamed to figure(2) while what I want to be figure(2) is named figure(1).
I think the issue is that imshow is displaying temp3 on both figure(1) and figure(2), but I don't understand why this would be happening. What should I change to ensure that I get the behavior I want (both images have their proper titles and figure labels)? Here's the code:
figure(1)
imshow(mat2gray(temp2));
title('After background subtraction and image thresholding')
figure(2)
imshow(mat2gray(temp3)); hold on
title('After peak detection')
scatter(good(1:no_good, 2), good(1:no_good, 1), 60, 'red')
impixelinfo;
hold off;
  3 件のコメント
Lakshay Sood
Lakshay Sood 2021 年 9 月 28 日
編集済み: Lakshay Sood 2021 年 9 月 28 日
I've checked the assignment into temp2 and temp3, but to no avail, unfortunately.
Let me try to provide a detailed explanation. I actually have six grayscale images - temp1, temp2, temp3, and (the last 3 are displayed as subplots on) temp4. In temp1, temp2, and temp3, the left half of the image is a copy of the right half of the image, except perhaps with some distortions and imperfections. Each of the "temps" should be displayed in a separate figure window. temp1, temp2, and temp3 are all declared as arrays of size 512 x 512, and 3 images of size 512 x 256 should be in the temp4 window. I am also calling
impixelinfo
below all of the imshow() calls to ensure that I have access to the intensity and coordinates of each pixel with my cursor.
I expect that each of temp1, temp2, and temp3 contain 1 image, properly titled. temp1 should show the raw image I am importing; temp2 should show the result of applying a boxcar filter to a copy of temp1; and temp3 should show a copy of temp2, except that I am attempting to draw blue circles around high-intensity spots that have been matched in temp1 and temp2 using
scatter().
Using the same function I would like to draw red circles around non-matched spots in temp3.
What I've noticed is that temp4 consistently renders correctly, as does temp3, except that it's often in the figure() window labeled "Figure 1". Meanwhile, temp1 and temp2 do appear in individual figure windows, but often without image titles. As a result it's almost impossible for me to distinguish between the two of them.
Kevin Holly
Kevin Holly 2021 年 9 月 29 日
I'm not sure why you are having an issue. You can name your figures if that will help you resolve the issue.
fh1 = figure('Name','Window 1')
imshow(mat2gray(temp2));
title('After background subtraction and image thresholding')
fh2 = figure('Name','Window 2')
imshow(mat2gray(temp3)); hold on
title('After peak detection')
scatter(good(1:no_good, 2), good(1:no_good, 1), 60, 'red')
impixelinfo;
hold off;
Are you selecting or moving the figures manually before running commands or are you running all the command at once?
In the code given, there is no instance of you using imshow for temp1 or temp4.

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

回答 (1 件)

yanqi liu
yanqi liu 2021 年 9 月 29 日
figure('Name', 'demo1', 'NumberTitle', 'off')
imshow(mat2gray(temp2));
title('After background subtraction and image thresholding')
figure('Name', 'demo2', 'NumberTitle', 'off')
imshow(mat2gray(temp3)); hold on
title('After peak detection')
scatter(good(1:no_good, 2), good(1:no_good, 1), 60, 'red')
impixelinfo;
hold off;

カテゴリ

Help Center および File ExchangeImages についてさらに検索

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by