We recently switched to an all-electric vehicle (the Chevy Bolt) and I wanted to investigate how the CO2 emissions compare to a conventional vehicle.
Sunday, April 15, 2018
Sunday, December 14, 2014
Choosing colors for scientific visualization: the RGB gamut in CIELUV
I make a lot of plots for work, and color is a very useful way to convey information. These colors are usually represented in RGB, especially when dealing with colors on a computer screen.
However, RGB does not do a good job of representing human perception of color. You will find that [0 255 0] (green) appears much brighter than [255 0 0] (red), which is in turn brighter than [0 0 255] (blue). Furthermore, if you sample uniformly from the RGB space, you will find that an unreasonably large fraction of this appears green.
There have been many attempts to parameterize color in a way that is more closely related to human perception. The one that I've been using is the CIE 1976 (L*, u*, v*) color space, aka CIELUV. The L* is supposed to represent the apparent brightness, and (u*, v*) parameterize the apparent color. It is supposed to do this in such a way that the distance between two points in the CIELUV space corresponds to how distinguishable the corresponding colors are to a human with trichromatic vision.
However, not everything in this color space is representable on a computer monitor. That is, not all of those points will fall within the RGB gamut. So without further ado, I present the RGB gamut in the CIELUV color space:
The boundaries are where one or more of the RGB coordinates saturate.
According to my friend, who (like 7% of American males) has impaired color vision, the color contrast is greatest traveling along the vertical (v*) axis. Of course, there are many ways in which your color vision could be impaired, so his experience is not representative of all color blind people.
More plots below:
However, RGB does not do a good job of representing human perception of color. You will find that [0 255 0] (green) appears much brighter than [255 0 0] (red), which is in turn brighter than [0 0 255] (blue). Furthermore, if you sample uniformly from the RGB space, you will find that an unreasonably large fraction of this appears green.
There have been many attempts to parameterize color in a way that is more closely related to human perception. The one that I've been using is the CIE 1976 (L*, u*, v*) color space, aka CIELUV. The L* is supposed to represent the apparent brightness, and (u*, v*) parameterize the apparent color. It is supposed to do this in such a way that the distance between two points in the CIELUV space corresponds to how distinguishable the corresponding colors are to a human with trichromatic vision.
However, not everything in this color space is representable on a computer monitor. That is, not all of those points will fall within the RGB gamut. So without further ado, I present the RGB gamut in the CIELUV color space:
The boundaries are where one or more of the RGB coordinates saturate.
According to my friend, who (like 7% of American males) has impaired color vision, the color contrast is greatest traveling along the vertical (v*) axis. Of course, there are many ways in which your color vision could be impaired, so his experience is not representative of all color blind people.
More plots below:
Wednesday, September 3, 2014
Garage door opener repair
A while back, our garage door opener (a Genie Pro 82 screw-drive) developed an odd problem: the light was stuck on. Normally, it is supposed to turn off a few minutes after use, but now it stopped turning off.
I reasoned that it was probably a relay that failed (it's always the moving parts that fail) and that it was stuck in the closed (i.e. "on") position. A quick search online confirmed that this is a common failure mode.
The opened opener:
I reasoned that it was probably a relay that failed (it's always the moving parts that fail) and that it was stuck in the closed (i.e. "on") position. A quick search online confirmed that this is a common failure mode.
The opened opener:
Tuesday, March 4, 2014
Printing on both sides
This keeps annoying me; I don't know why it keeps coming up.
My printer has a duplexer, but sometimes Windows 7 forgets about it. HP has a help page about it, the gist of which is:
Control Panel -> Right-click on your printer -> Printer properties -> Device Settings
Set "Duplex Unit" to "Installed" and, to reduce confusion, set "Allow manual duplexing" to "Disabled"
Tuesday, February 18, 2014
Terminal adventures
I do a lot of work remotely for work. Somewhere in the server room there is a beast of a computer with 100's of GB of RAM and a 10-gigabit connection to a dozen other computers hosting half a petabyte of storage.
Mostly I work in MATLAB. If I need graphics, we have a nice OpenNX setup that does remote desktop quite well. It's nearly seamless when I'm on-site, and is still tolerable when I use it from home over DSL (as long as nobody else at home is using the upload capacity).
But often I don't need full graphics, just a text editor and the MATLAB command window. So in today's adventure, we are going to try setting up tmux and vim.
Monday, September 2, 2013
Xbox 360: 120mm fan mod for quietness
I wanted to watch a movie yesterday, but my Xbox's fans are too loud. So I decided to do something about it!
Batch photo resize preserving modify date
On Mac OS with ImageMagick installed (see also this older post):
mkdir resized
cp 2013-09-02*.jpg resized
mogrify -resize 3056x3056 resized/*.jpg
find resized -name "*.jpg" | sed "s/resized\///" | xargs -I {} touch -r "{}" "resized/{}"
mv resized/*.jpg .
rmdir resized
The crazy find/sed/xargs thing does the following:
mkdir resized
cp 2013-09-02*.jpg resized
mogrify -resize 3056x3056 resized/*.jpg
find resized -name "*.jpg" | sed "s/resized\///" | xargs -I {} touch -r "{}" "resized/{}"
mv resized/*.jpg .
rmdir resized
The crazy find/sed/xargs thing does the following:
- find : Find all the jpg files in the "resized" folder and return their relative path.
- sed : Find and replace all instances of "resized/" with an empty string. sed returns the full string with replacements, not just the match.
- xargs touch : Change each of the files in the "resized" folder to have the same modify date
Monday, July 22, 2013
Git rebase
After seing git rebase show up on StackOverflow a few times and purposely ignoring it (due to the overhead required to learn a new git command), I finally broke down and learned what it does.
And it turns out it's not that bad! The git book has a good page introducing it with nice pictures:
http://git-scm.com/book/en/Git-Branching-Rebasing
and I'll describe how I applied it to my particular situation.
git diff --name-status origin/develop..develop
Now if I wanted to make all of those changes, I can just do git push origin, and it would be done. Instead I want to make a subset of those changes, but I can't just arbitrarily pick changes because maybe some of them depend on previous commits.
That's how rebase helps: it lets us re-order the commits. It puts all of the remote changes first (this makes pushing trivial), and then it applies our local changes in whatever order we tell it to. So we do:
git rebase -i origin/develop
and this opens up a text editor with all the local changes that have happened since we first diverged from origin/develop. We can rearrange the commits, collapse multiple commits into one using squash, and do all sorts of other things that are covered in this tutorial. In my case, I simply moved the changes I wanted pushed to the top of the list.
Once we save and close this file, git-rebase will try to apply each of those changes, in sequence, using origin/develop as a starting point. This may not proceed entirely smoothly, especially if you have re-ordered some commits.
Once this is finished, I go find the hash of the last commit I want pushed and push all the commits up to that one:
git push origin 1fc6c95:develop
And that's that!
And it turns out it's not that bad! The git book has a good page introducing it with nice pictures:
http://git-scm.com/book/en/Git-Branching-Rebasing
and I'll describe how I applied it to my particular situation.
Scenario
I have been pulling from a repository at origin/develop, but also making local changes and committing them to my local repository. Now I want to push some (but not all) of the changes to origin/develop.Procedure
First, I wanted to see how my local repository (currently on branch develop) differed from origin/develop:git diff --name-status origin/develop..develop
Now if I wanted to make all of those changes, I can just do git push origin, and it would be done. Instead I want to make a subset of those changes, but I can't just arbitrarily pick changes because maybe some of them depend on previous commits.
That's how rebase helps: it lets us re-order the commits. It puts all of the remote changes first (this makes pushing trivial), and then it applies our local changes in whatever order we tell it to. So we do:
git rebase -i origin/develop
and this opens up a text editor with all the local changes that have happened since we first diverged from origin/develop. We can rearrange the commits, collapse multiple commits into one using squash, and do all sorts of other things that are covered in this tutorial. In my case, I simply moved the changes I wanted pushed to the top of the list.
Once we save and close this file, git-rebase will try to apply each of those changes, in sequence, using origin/develop as a starting point. This may not proceed entirely smoothly, especially if you have re-ordered some commits.
Once this is finished, I go find the hash of the last commit I want pushed and push all the commits up to that one:
git push origin 1fc6c95:develop
And that's that!
Sunday, April 28, 2013
Fish tube, again
We re-installed the fish tube, and it seems to be much more popular this time around! Everybody's had a turn at it: the rasboras, panda cory, Amano shrimp, and even our nerite snail! The snail must have climbed up on a plant or something, because the tube doesn't touch the walls of the tank.
There is regularly at least one rasbora in the tube. It's usually a different rasbora each day, which is a relief.
Pita bread
Had leftover chicken from Zankou, but no pita to go with it, so I decided to make some!
I followed this recipe, paraphrased here:
I followed this recipe, paraphrased here:
- 227 g (~1.5 C) flour
- 65% water
- 6% olive/canola oil
- 1.5% dry yeast
- 2.7% salt
Percentages are by mass, relative to flour. Special thanks to my roommate, who bought a 2 kg digital scale and a thermocouple reader for his coffee-making.
Let rise for 5 hr at 22°C. This produces a lot more gas than my usual bread recipe at the same temperature, probably due to the increased amount of yeast. Punch down, let rise for another half hour or so.
Preheat oven, with baking stone, to 475°F.
Divide dough into 6 balls. Flatten into discs and then roll out with a rolling pin.
Sprinkle some water on top, and let sit for 10 min or so. Ensure bottom is well-floured, and slide onto baking stone. Bake for 3 min.
Magically, it ballons up and then you get a pita! I still don't understand how this happened.
And it came out pretty good! A bit salty, but that wasn't so noticeable after filling it with chicken and garlic sauce and hummus. Need to be careful not to get it too thin during the rolling and handling process.
Preheat oven, with baking stone, to 475°F.
Divide dough into 6 balls. Flatten into discs and then roll out with a rolling pin.
Sprinkle some water on top, and let sit for 10 min or so. Ensure bottom is well-floured, and slide onto baking stone. Bake for 3 min.
Magically, it ballons up and then you get a pita! I still don't understand how this happened.
And it came out pretty good! A bit salty, but that wasn't so noticeable after filling it with chicken and garlic sauce and hummus. Need to be careful not to get it too thin during the rolling and handling process.
Subscribe to:
Posts (Atom)







