Change image colormap to deuteranopia in Matlab - image

I've been trying for a long time to change my colormap of my images using a custom 256x3 colormap to switch the impression of a 'normal sighted' person to the one a person with deuteranopia (red-green-blindness) can see.
The colormap has already been created, but in no way I get to apply it to the original image.
The code
load('ColormapsDefVis.mat')
fig=figure
a=imread('Regenbogen.png');
[b map]=rgb2ind(a,256);
c=ind2rgb(b, DeuteranopiaColorMap);
imshow(c);
did not work as well as
load('ColormapsDefVis.mat')
fig=figure
a=imread('Regenbogen.png');
imshow(a);
set(fig,'Colormap',DeuteranopiaColorMap)
did not.
Does anyone know how to change the custom colormap correctly?
I would appreciate your help very much!

The first peice of code works. You have to be making a mistake or interpreting the results wrongly.
I suggest you look a to a thing. Make sure you image is unit8 or single. Additionally, you probably dont what dithering to happen, so I suggest you do rgb2ind(a,256, 'nodither'). The results of the dithering may be fooling your eyes, but we can't know as you didn't post any image.
To convince yourself that rgb2ind works, see the code below. You should be able to test it in you computer.
img=imread('cameraman.tif');
indimg=img;
cmap=hsv(255); % colromap 1
cmap2=cmap(end:-1:1,:); % colromap 2
subplot(121);
c=ind2rgb(indimg,cmap );
imshow(c)
subplot(122);
c2=ind2rgb(indimg,cmap2 );
imshow(c2)

Thank you very much for your help Ander, the approach using colormaps was just not the efficient solution i was looking for. Although I am sure it would work too, there is a way easier solution for the problem :)
To receive the impression of being red-green-blind I took the idea that people suffering from this condition cannot distinguish between reddish and greenish objects. So my solution is to plot the mean from the red and green RGB-image channel in both channels to make them indistinguishable.
a=imread('peppers.png');
figure,
subplot(121)
imshow(a)
c=(a(:,:,1)+a(:,:,2))/2; %Mean value between channel red and green
a(:,:,1)=c; %Switch the red channel to the mean
a(:,:,2)=c; %Switch the green channel to the mean
subplot(122)
imshow(a)
Unfortunately, stackoverflow refuses me to upload images as I do not have enough reputation, but the code shall work using any RGB-image, for example the builtin demo image 'peppers.png'.
Hope this helps anyone else too!

Related

How would I go about swapping different transparent images with others in visual basic 6?

So I have a programming project that I have to do for my school. What I have to do is setup a 2 player dice game. I could have gone the easy way and just display the number of the 2 die, but I was thinking of using images that I made in photoshop instead. However, the problem is that I do not know how to change images in an efficient way.
My first option is using the visibility tag on several images laid on top of eachother and change it accordingly as such
image1.visible = false
image2.visible = true
However, I do not think that is very efficient. Images also do not support changing the image with code from my research.
Secondly, I could use a PictureBox instead, which do support changing the image as the program is running. However, it does not support transparency, and the die images are transparent. Plus it gives me the invalid image file error, I guess due to the transparency in the gif files.
There is also the cheap workaround of me making the background of the images the same as the form background.
So is there a more efficient way I am missing out? I know that the cheap workaround would be the best option for this case, but I would like to have this knowledge for future use like semi-transparent pixels that blend in and such.
And before you ask, no, I cannot use another programming language as visual basic 6 is what my school teaches. Thankfully they are changing it soon, but I am stuck with this for now.
Turns out you CAN change the pictures of Images, while keeping transparency and stretch. I am going to properly show it:
Image1.Picture = LoadPicture("YOURPATHHERE.gif")
This is what I get for believing what I've seen on some forum.
Also, the error of invalid image file was due to the images being corrupted for some reason.

Shifting image behind perlin noise flow field doesn't work in Atom

I would really appreciate it if someone could help me out. I made a Perlin Noise flow field in Atom. Behind that flow field I set an image and that worked fine. But when I want to make that image shift a bit to the right after x seconds (and back), I don't get it to work. The flow field is now behind the image instead of the other way around.
I get that the flow field starts in the setup and thats the reason why I can't set my image in the draw, but does someone know a solution?
You can see my code on: https://www.openprocessing.org/sketch/423718
Thanks in advance! :)

transparencize a background image on Photoshop

I would like to use this background image on different pages of my website.
The idea is to have a different color, instead of being grey. I am trying to change the color on Photoshop, and found this topic: https://graphicdesign.stackexchange.com/questions/4056/replace-black-background-with-a-transparent-background but the result is not the one I was expecting.
Anyone knows how to do this ?
yes, you can change it with Photoshop.
Follow these easy steps:
1. Go to main navigation - Images -> Adjustments -> Hue/Saturation...
You must select "Colorize", then you can play with the Hue to find your color and with the saturation to saturate it.
Enjoy! :)
I think this should be in Graphic Design rather than on Stack Overflow, unless you're looking for someway to do it with Photoshop scripting.
If you're looking for simply changing the shade from gray to say orange or green. I would select the layer then go to Image>Adjustments and play around with Hue/Saturation. Play around with that. There may be another way to do it but that's what I would do.

Dynamically(at some time intervals) change textures on a plane/cube in three.js?

I know it's something with texture.needsUpdate() while rendering but I don't have a clue how to actually implement it. Maybe someone knows a link where I can see a working example or post some piece of code? Cheers.
An excellent question; I created some sample code to do exactly this -- using a spritesheet to do some 2D animation on a plane and on a cube, which requires regular updates. Here is a link to a documented example, that in particular contains a function to do exactly what you need.
http://stemkoski.github.com/Three.js/Texture-Animation.html
Hope it helps!

Using QCView and iSight to capture image

I have a QCView that loads a Quartz file which gives you iSights feedback (basically like a QTCaptureView)
Everything displays fine
The button simply takes a snapshot using the following simple lines of code
- (void)takePicture:(id)sender {NSImage *currentImage = [outputView valueForOutputKey:#"ImageOutput"];
[[currentImage TIFFRepresentation] writeToFile:#"/Users/hendo13/Desktop/capture.tiff" atomically:NO];}
The exported image however has some very wonky colouring issues like so:
http://kttns.org/gjhnj
No filters of any sort have been applied. Does anyone know what is causing this?
It's inverted. You can use the CIInvert filter to correct it (assuming there's no way to correct the actual output of the QC view).
Oh, and I think the blue and green alpha channels are the wrong way around, too (possibly an endianness problem?). If you go with the CIInvert solution, you can use CIColorMatrix to rearrange the channels, swapping blue and green back to their proper places. Here's a tutorial I wrote for it—I wrote it for the user interface in Core Image Fun House, but using it programmatically shouldn't be too hard once you understand how the filter works.

Resources