Artifacts appear on my matlab image (2024)

39 views (last 30 days)

Show older comments

Tina on 20 Aug 2024 at 13:05

  • Link

    Direct link to this question

    https://ms-www.mathworks.com/matlabcentral/answers/2146619-artifacts-appear-on-my-matlab-image

  • Link

    Direct link to this question

    https://ms-www.mathworks.com/matlabcentral/answers/2146619-artifacts-appear-on-my-matlab-image

Commented: Tina on 23 Aug 2024 at 9:19

Hello everyone,

I wrote a matlab program to process my data, the results and in the form of image of different colors. The color scale is a choice and this is the problem, because when I use a colormap with 3 different colors I don't have this artifact that appears but when I use the one with the rainbow colors the artifact appears. I'm attaching the image and the code snippet for the colormap. Do you have any idea why I'm having this problem? How can I fix it?

Artifacts appear on my matlab image (2)

Artifacts appear on my matlab image (3)

Artifacts appear on my matlab image (4)

1 Comment

Show -1 older commentsHide -1 older comments

Cris LaPierre on 20 Aug 2024 at 13:45

Direct link to this comment

https://ms-www.mathworks.com/matlabcentral/answers/2146619-artifacts-appear-on-my-matlab-image#comment_3241794

  • Link

    Direct link to this comment

    https://ms-www.mathworks.com/matlabcentral/answers/2146619-artifacts-appear-on-my-matlab-image#comment_3241794

Edited: Cris LaPierre on 20 Aug 2024 at 13:52

Open in MATLAB Online

k = [0 0 0]; %# start

p = [1 0 1];

n = [0 0 1];

b = [0 1 1];

g = [0 1 0]; %# middle

y = [1 1 0];

r = [1 0 0];

z = [0 0 0];%# end

% Colormap de taille 64x3, dégradée en arc-en-ciel

cl = zeros (32,3); c2 = zeros (32,3); c3 = zeros (32,3); c4 = zeros (32,3);

c5 = zeros (32,3); c6 = zeros (32,3); c7 = zeros (32,3);

for i = 1:3

cl(:,i) = linspace (k(i), p(i), 32);

c2(:,i) = linspace (p(i), n(i), 32);

c3(:,i) = linspace (n(i), b(i), 32);

c4(:,i) = linspace (b(i), g(i), 32);

c5(:,i) = linspace (g(i), y(i), 32);

c6(:,i) = linspace (y(i), r(i), 32);

c7(:,i) = linspace (r(i), z(i), 32);

end

% Combinaison de toutes les parties sans doublons

c = [cl(1:end-1,:); c2(1:end-1,:); c3(1:end-1,:); c4(1:end-1,:); c5(1:end-1,:); c6(1:end-1,:); c7];

% Afficher la surface

surf (peaks), shading interp

caxis([-1 1])

colormap(c)

colorbar

Artifacts appear on my matlab image (6)

Sign in to comment.

Sign in to answer this question.

Answers (1)

Cris LaPierre on 20 Aug 2024 at 13:47

  • Link

    Direct link to this answer

    https://ms-www.mathworks.com/matlabcentral/answers/2146619-artifacts-appear-on-my-matlab-image#answer_1501814

  • Link

    Direct link to this answer

    https://ms-www.mathworks.com/matlabcentral/answers/2146619-artifacts-appear-on-my-matlab-image#answer_1501814

We'd have to see your code for 3 colors to say for certain, but here, your colormap sets anything above or below abs(1) to [0 0 0], or black. We don't have your processed data, but it would appear the region of the artifact must contain absolute values >= 1.

14 Comments

Show 12 older commentsHide 12 older comments

Tina on 20 Aug 2024 at 15:27

Direct link to this comment

https://ms-www.mathworks.com/matlabcentral/answers/2146619-artifacts-appear-on-my-matlab-image#comment_3241909

  • Link

    Direct link to this comment

    https://ms-www.mathworks.com/matlabcentral/answers/2146619-artifacts-appear-on-my-matlab-image#comment_3241909

Edited: Walter Roberson on 20 Aug 2024 at 19:10

Open in MATLAB Online

I've commented on the absolute value as you can see from the photo, but the problem persists.

Artifacts appear on my matlab image (9)

For the colormaps code which contains only 3 colors (in reality we have 5 colors with two blue and two red), here it is at the bottom, you can see on the result picture that in this case I don't have an artifact even though it's the same data.

%----------------------------------------------------------------------------------bleu-blanc-rouge----------------------------

B = [0.0840 0.1747 0.3910]; %# start

b = [0 0 1];

g=[0.8290,0.8940, 0.0250]; %# middle

r = [1 0 0];

R = [0.6350 0.0780 0.1840]; %# end

%colormap of size 64-by-3

c1 = zeros(32,3); c2 = zeros(32,3);c3 = zeros(32,3);c4 = zeros(32,3);

for i=1:3

c1(:,i) = linspace(B(i), b(i), 32);

c2(:,i) = linspace(b(i), g(i), 32);

c3(:,i) = linspace(g(i), r(i), 32);

c4(:,i) = linspace(r(i), R(i), 32);

end

c = [c1(1:end-1,:);c2;c3;c4];

%surf(peaks),

shading interp

caxis([-1 1])

colormap (c)

%--------------------------------------------------------------------------------

Artifacts appear on my matlab image (10)

Cris LaPierre on 20 Aug 2024 at 15:43

  • Link

    Direct link to this comment

    https://ms-www.mathworks.com/matlabcentral/answers/2146619-artifacts-appear-on-my-matlab-image#comment_3241929

Edited: Cris LaPierre on 20 Aug 2024 at 15:44

The difference is in your colormap. In the 7 color example (the one with the artifact), your colormap starts and ends with black. In your 3 color example, the colormap starts with blue and ends with red. If you do not want black in the extremes of your colormap, you must not include it when building your colormap variable.

In order for us to play around with your example, please share your processed data. You can save your variable(s) to a mat file and then attach it to your post using the paperclip icon.

Tina on 20 Aug 2024 at 16:16

Direct link to this comment

https://ms-www.mathworks.com/matlabcentral/answers/2146619-artifacts-appear-on-my-matlab-image#comment_3241949

  • Link

    Direct link to this comment

    https://ms-www.mathworks.com/matlabcentral/answers/2146619-artifacts-appear-on-my-matlab-image#comment_3241949

  • V.mat

I got rid of the black at the beginning and end, but the problem is still there. I'm sending you my V value file as you requested.

Tina on 20 Aug 2024 at 16:24

Direct link to this comment

https://ms-www.mathworks.com/matlabcentral/answers/2146619-artifacts-appear-on-my-matlab-image#comment_3241964

  • Link

    Direct link to this comment

    https://ms-www.mathworks.com/matlabcentral/answers/2146619-artifacts-appear-on-my-matlab-image#comment_3241964

Artifacts appear on my matlab image (14)

Cris LaPierre on 20 Aug 2024 at 17:14

Direct link to this comment

https://ms-www.mathworks.com/matlabcentral/answers/2146619-artifacts-appear-on-my-matlab-image#comment_3242014

  • Link

    Direct link to this comment

    https://ms-www.mathworks.com/matlabcentral/answers/2146619-artifacts-appear-on-my-matlab-image#comment_3242014

The code you have shared does not create the figure you are showing. Please share all the relevant code so that we can duplicate the issue.

Tina on 20 Aug 2024 at 19:06

Direct link to this comment

https://ms-www.mathworks.com/matlabcentral/answers/2146619-artifacts-appear-on-my-matlab-image#comment_3242179

  • Link

    Direct link to this comment

    https://ms-www.mathworks.com/matlabcentral/answers/2146619-artifacts-appear-on-my-matlab-image#comment_3242179

  • V.mat

Try with this

Cris LaPierre on 20 Aug 2024 at 19:17

Direct link to this comment

https://ms-www.mathworks.com/matlabcentral/answers/2146619-artifacts-appear-on-my-matlab-image#comment_3242194

  • Link

    Direct link to this comment

    https://ms-www.mathworks.com/matlabcentral/answers/2146619-artifacts-appear-on-my-matlab-image#comment_3242194

Open in MATLAB Online

The only code that creates a figure in the code you have shared is surf(peaks). However, that does not create your image.

surf(peaks)

Artifacts appear on my matlab image (18)

Cris LaPierre on 20 Aug 2024 at 19:28

Direct link to this comment

https://ms-www.mathworks.com/matlabcentral/answers/2146619-artifacts-appear-on-my-matlab-image#comment_3242214

  • Link

    Direct link to this comment

    https://ms-www.mathworks.com/matlabcentral/answers/2146619-artifacts-appear-on-my-matlab-image#comment_3242214

Open in MATLAB Online

  • V.mat

Here is my best guess at what you may be doing. Note that it does not show the artifact. The code you have not shared must be doing something additional to the data that is causing the artifact to appear.

load V.mat

surf(X,Y,V1,'LineStyle','none')

view(2)

%----------------------------------------------------------------------------------bleu-blanc-rouge----------------------------

B = [0.0840 0.1747 0.3910]; %# start

b = [0 0 1];

g=[0.8290,0.8940, 0.0250]; %# middle

r = [1 0 0];

R = [0.6350 0.0780 0.1840]; %# end

%colormap of size 64-by-3

c1 = zeros(32,3); c2 = zeros(32,3);c3 = zeros(32,3);c4 = zeros(32,3);

for i=1:3

c1(:,i) = linspace(B(i), b(i), 32);

c2(:,i) = linspace(b(i), g(i), 32);

c3(:,i) = linspace(g(i), r(i), 32);

c4(:,i) = linspace(r(i), R(i), 32);

end

c = [c1(1:end-1,:);c2;c3;c4];

% surf(peaks),

shading interp

caxis([-1 1])

colormap(c)

colorbar

Artifacts appear on my matlab image (20)

%----------------

figure

surf(X,Y,V1,'LineStyle','none')

view(2)

k = [0 0 0]; %# start

p = [1 0 1];

n = [0 0 1];

b = [0 1 1];

g = [0 1 0]; %# middle

y = [1 1 0];

r = [1 0 0];

z = [0 0 0];%# end

% Colormap de taille 64x3, dégradée en arc-en-ciel

cl = zeros (32,3); c2 = zeros (32,3); c3 = zeros (32,3); c4 = zeros (32,3);

c5 = zeros (32,3); c6 = zeros (32,3); c7 = zeros (32,3);

for i = 1:3

cl(:,i) = linspace (k(i), p(i), 32);

c2(:,i) = linspace (p(i), n(i), 32);

c3(:,i) = linspace (n(i), b(i), 32);

c4(:,i) = linspace (b(i), g(i), 32);

c5(:,i) = linspace (g(i), y(i), 32);

c6(:,i) = linspace (y(i), r(i), 32);

c7(:,i) = linspace (r(i), z(i), 32);

end

% Combinaison de toutes les parties sans doublons

c = [cl(1:end-1,:); c2(1:end-1,:); c3(1:end-1,:); c4(1:end-1,:); c5(1:end-1,:); c6(1:end-1,:); c7];

% Afficher la surface

caxis([-1 1])

colormap(c)

colorbar

Artifacts appear on my matlab image (21)

Tina on 21 Aug 2024 at 9:13

Direct link to this comment

https://ms-www.mathworks.com/matlabcentral/answers/2146619-artifacts-appear-on-my-matlab-image#comment_3242609

  • Link

    Direct link to this comment

    https://ms-www.mathworks.com/matlabcentral/answers/2146619-artifacts-appear-on-my-matlab-image#comment_3242609

Edited: Cris LaPierre on 21 Aug 2024 at 13:53

Open in MATLAB Online

  • Au_Triangle_Index.txt
  • V.mat

Here is my entire code, i use the txt file 'index' for the triangle contour.

Thanks again for your help.

%% Edit to run code here

load V.mat

index = readmatrix('Au_Triangle_Index.txt');

x = X;

y = Y;

k = [0 0 0]; %# start

p = [1 0 1];

n = [0 0 1];

b = [0 1 1];

g = [0 1 0]; %# middle

yy = [1 1 0];

r = [1 0 0];

z = [0 0 0];%# end

% Colormap de taille 64x3, dégradée en arc-en-ciel

cl = zeros(32,3); c2 = zeros(32,3); c3 = zeros(32,3); c4 = zeros(32,3);

c5 = zeros(32,3); c6 = zeros(32,3); c7 = zeros(32,3);

for i = 1:3

cl(:,i) = linspace (k(i), p(i), 32);

c2(:,i) = linspace (p(i), n(i), 32);

c3(:,i) = linspace (n(i), b(i), 32);

c4(:,i) = linspace (b(i), g(i), 32);

c5(:,i) = linspace (g(i), yy(i), 32);

c6(:,i) = linspace (yy(i), r(i), 32);

c7(:,i) = linspace (r(i), z(i), 32);

end

% Combinaison de toutes les parties sans doublons

c = [cl(1:end-1,:); c2(1:end-1,:); c3(1:end-1,:); c4(1:end-1,:); c5(1:end-1,:); c6(1:end-1,:); c7];

%%---------------------------------------------------------------------------

figure % Complete

hold all

pcolor(X,Y,V1)

contour(x,y,real(index'),'linecolor','G');

colorbar

%box on

AX=gca;

AX.LineWidth=2;

AX.FontSize=14;

AX.TickLength=[0.02 0.02];

AX.XTick=-300:150:300;

AX.YTick=-300:150:300;

axis tight

%xlabel('X position (nm)','Fontsize',18,'FontWeight','bold')

%ylabel('Y position (nm)','Fontsize',18,'FontWeight','bold')

axis equal

%axis([-160-Rod_Width-Gap_Width/2,160+Rod_Width+Gap_Width/2,-160-Rod_Length+Gap_Length/2,160+Rod_Length-Gap_Length/2])

%axis([-40-Rod_Width-Gap_Width/2,40+Rod_Width+Gap_Width/2,-150-Rod_Length+Gap_Length/2,150+Rod_Length-Gap_Length/2])

colorbar

CA=caxis;

CB=colorbar;

CB.LineWidth=1;

CB.FontSize=14;

CB.Ticks=-10:1:10;

CB.Label.String='V';

CB.Label.FontSize=18;

CB.Label.FontWeight='bold';

Artifacts appear on my matlab image (23)

figure % Axis only

colormap (c)

shading interp

box on

AX=gca;

AX.LineWidth=2;

AX.FontSize=14;

AX.TickLength=[0.02 0.02];

AX.XTick=-300:150:300;

AX.YTick=-300:150:300;

%xlabel('X position (nm)','Fontsize',18,'FontWeight','bold')

%ylabel('Y position (nm)','Fontsize',18,'FontWeight','bold')

%axis equal

%axis([-80-Rod_Width-Gap_Width/2,80+Rod_Width+Gap_Width/2,-80-Rod_Length+Gap_Length/2,80+Rod_Length-Gap_Length/2])

%axis([-40-Rod_Width-Gap_Width/2,40+Rod_Width+Gap_Width/2,-150-Rod_Length+Gap_Length/2,150+Rod_Length-Gap_Length/2])

axis tight

colorbar

caxis(CA);

CB=colorbar;

CB.LineWidth=1;

CB.FontSize=14;

CB.Ticks=-10:1:10;

CB.Label.String='V';

CB.Label.FontSize=18;

CB.Label.FontWeight='bold';

Artifacts appear on my matlab image (24)

Cris LaPierre on 21 Aug 2024 at 13:56

Direct link to this comment

https://ms-www.mathworks.com/matlabcentral/answers/2146619-artifacts-appear-on-my-matlab-image#comment_3242839

  • Link

    Direct link to this comment

    https://ms-www.mathworks.com/matlabcentral/answers/2146619-artifacts-appear-on-my-matlab-image#comment_3242839

Edited: Cris LaPierre on 21 Aug 2024 at 15:33

I've edited your post so that the code can be run here. This does not generate the figure you are asking about. Could you share a working example that recreates the issue? Use the green play button in the toolstrip to run your code here.

Tina on 21 Aug 2024 at 15:11

Direct link to this comment

https://ms-www.mathworks.com/matlabcentral/answers/2146619-artifacts-appear-on-my-matlab-image#comment_3242904

  • Link

    Direct link to this comment

    https://ms-www.mathworks.com/matlabcentral/answers/2146619-artifacts-appear-on-my-matlab-image#comment_3242904

Edited: Cris LaPierre on 21 Aug 2024 at 15:32

Open in MATLAB Online

  • Au_Triangle_Index.txt
  • V.mat

figure

index=dlmread('Au_Triangle_Index.txt');

%% Edit so that code runs here

load V.mat

x = X; y = Y;

% [X,Y]=meshgrid(x,y);

%% -----------------------------------------

hold all

contour(x,y,real(index'),'linecolor','G');

surf(X,Y,V1,'LineStyle','none')

view(2)

k = [0 0 0]; %# start

p = [1 0 1];

n = [0 0 1];

b = [0 1 1];

g = [0 1 0]; %# middle

y = [1 1 0];

r = [1 0 0];

z = [0 0 0];%# end

% Colormap de taille 64x3, dégradée en arc-en-ciel

cl = zeros (32,3); c2 = zeros (32,3); c3 = zeros (32,3); c4 = zeros (32,3);

c5 = zeros (32,3); c6 = zeros (32,3); c7 = zeros (32,3);

for i = 1:3

cl(:,i) = linspace (k(i), p(i), 32);

c2(:,i) = linspace (p(i), n(i), 32);

c3(:,i) = linspace (n(i), b(i), 32);

c4(:,i) = linspace (b(i), g(i), 32);

c5(:,i) = linspace (g(i), y(i), 32);

c6(:,i) = linspace (y(i), r(i), 32);

c7(:,i) = linspace (r(i), z(i), 32);

end

% Combinaison de toutes les parties sans doublons

c = [cl(1:end-1,:); c2(1:end-1,:); c3(1:end-1,:); c4(1:end-1,:); c5(1:end-1,:); c6(1:end-1,:); c7];

% Afficher la surface

caxis([-1 1])

colormap(c)

colorbar

colorbar

%box on

AX=gca;

AX.LineWidth=2;

AX.FontSize=14;

AX.TickLength=[0.02 0.02];

AX.XTick=-300:150:300;

AX.YTick=-300:150:300;

axis tight

%xlabel('X position (nm)','Fontsize',18,'FontWeight','bold')

%ylabel('Y position (nm)','Fontsize',18,'FontWeight','bold')

axis equal

%axis([-160-Rod_Width-Gap_Width/2,160+Rod_Width+Gap_Width/2,-160-Rod_Length+Gap_Length/2,160+Rod_Length-Gap_Length/2])

%axis([-40-Rod_Width-Gap_Width/2,40+Rod_Width+Gap_Width/2,-150-Rod_Length+Gap_Length/2,150+Rod_Length-Gap_Length/2])

colorbar

CA=caxis;

CB=colorbar;

CB.LineWidth=1;

CB.FontSize=14;

CB.Ticks=-10:1:10;

CB.Label.String='V';

CB.Label.FontSize=18;

CB.Label.FontWeight='bold';

Artifacts appear on my matlab image (27)

Tina on 21 Aug 2024 at 15:12

Direct link to this comment

https://ms-www.mathworks.com/matlabcentral/answers/2146619-artifacts-appear-on-my-matlab-image#comment_3242909

  • Link

    Direct link to this comment

    https://ms-www.mathworks.com/matlabcentral/answers/2146619-artifacts-appear-on-my-matlab-image#comment_3242909

it works now :)

Cris LaPierre on 21 Aug 2024 at 15:33

Direct link to this comment

https://ms-www.mathworks.com/matlabcentral/answers/2146619-artifacts-appear-on-my-matlab-image#comment_3242934

  • Link

    Direct link to this comment

    https://ms-www.mathworks.com/matlabcentral/answers/2146619-artifacts-appear-on-my-matlab-image#comment_3242934

Great to hear. I've edited your post so that your code runs here as well, showing no artifact.

Tina on 23 Aug 2024 at 9:19

Direct link to this comment

https://ms-www.mathworks.com/matlabcentral/answers/2146619-artifacts-appear-on-my-matlab-image#comment_3244654

  • Link

    Direct link to this comment

    https://ms-www.mathworks.com/matlabcentral/answers/2146619-artifacts-appear-on-my-matlab-image#comment_3244654

Thank you very much for your invaluable help.

Sign in to comment.

Sign in to answer this question.

See Also

Categories

MATLABGraphicsFormatting and AnnotationColormapsWhite

Find more on White in Help Center and File Exchange

Tags

  • colourmap
  • image processing

Community Treasure Hunt

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

Start Hunting!

An Error Occurred

Unable to complete the action because of changes made to the page. Reload the page to see its updated state.


Artifacts appear on my matlab image (31)

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list

Americas

  • América Latina (Español)
  • Canada (English)
  • United States (English)

Europe

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom(English)

Asia Pacific

  • Australia (English)
  • India (English)
  • New Zealand (English)
  • 中国
  • 日本Japanese (日本語)
  • 한국Korean (한국어)

Contact your local office

Artifacts appear on my matlab image (2024)

References

Top Articles
Tui Skyla French Balcony Suite Full Review
Is It Worth Getting A Balcony On A Cruise?
Netronline Taxes
Exclusive: Baby Alien Fan Bus Leaked - Get the Inside Scoop! - Nick Lachey
What happens if I deposit a bounced check?
15 Types of Pancake Recipes from Across the Globe | EUROSPAR NI
Unraveling The Mystery: Does Breckie Hill Have A Boyfriend?
Craigslist Dog Sitter
Jscc Jweb
Brenna Percy Reddit
Taylor Swift Seating Chart Nashville
4302024447
Identogo Brunswick Ga
Busty Bruce Lee
ARK: Survival Evolved Valguero Map Guide: Resource Locations, Bosses, & Dinos
U Break It Near Me
Fsga Golf
Gazette Obituary Colorado Springs
Why Are Fuel Leaks A Problem Aceable
480-467-2273
4 Times Rihanna Showed Solidarity for Social Movements Around the World
Hdmovie2 Sbs
Hobby Lobby Hours Parkersburg Wv
Evil Dead Rise Ending Explained
Weather October 15
Xxn Abbreviation List 2023
Stickley Furniture
Rs3 Bring Leela To The Tomb
Sony Wf-1000Xm4 Controls
Darktide Terrifying Barrage
ATM, 3813 N Woodlawn Blvd, Wichita, KS 67220, US - MapQuest
Pdx Weather Noaa
Haunted Mansion Showtimes Near Cinemark Tinseltown Usa And Imax
Mumu Player Pokemon Go
Pch Sunken Treasures
Cars And Trucks Facebook
Gideon Nicole Riddley Read Online Free
24 slang words teens and Gen Zers are using in 2020, and what they really mean
Makemkv Key April 2023
Domina Scarlett Ct
Final Fantasy 7 Remake Nexus
Callie Gullickson Eye Patches
Luvsquad-Links
Dragon Ball Super Super Hero 123Movies
Craigslist Com St Cloud Mn
Grand Valley State University Library Hours
Tlc Africa Deaths 2021
Gw2 Support Specter
Advance Auto.parts Near Me
Strawberry Lake Nd Cabins For Sale
Skyward Login Wylie Isd
Samantha Lyne Wikipedia
Latest Posts
Article information

Author: Geoffrey Lueilwitz

Last Updated:

Views: 5475

Rating: 5 / 5 (60 voted)

Reviews: 91% of readers found this page helpful

Author information

Name: Geoffrey Lueilwitz

Birthday: 1997-03-23

Address: 74183 Thomas Course, Port Micheal, OK 55446-1529

Phone: +13408645881558

Job: Global Representative

Hobby: Sailing, Vehicle restoration, Rowing, Ghost hunting, Scrapbooking, Rugby, Board sports

Introduction: My name is Geoffrey Lueilwitz, I am a zealous, encouraging, sparkling, enchanting, graceful, faithful, nice person who loves writing and wants to share my knowledge and understanding with you.