max grosse

2011-06-07 16:21

When you want to create seamlessly tiling textures out of some photographs, usually a lot of manual work using some image editing software becomes necessary. Just using the image right away will create ugly seams.

Inspired by the wonderful paper on graph cuts for image and video synthesis, I implemented the algorithm in a more simple form, suitable for creating seamlessly tiling images. Now, the user is just required to adjust an amount of horizontal and vertical overlap and in some seconds a seamless version is created.

The core of the algorithm is the Boykov/Kolmogorov graph cut algorithm, which is implemented already in the boost library, ready for use. So in fact, most of my development time I've spent on creating a nice application for MacOS X which is hopefully easy and intuitive to use.
You can try out a preview version, still including some bugs and several memory leaks here:
Note, that the application is MacOS X 10.6 only, built for x86 and provided to you as is. I'll try to improve it in my spare time to fix all the remaining bugs and leaks and add some useful features, but for now it appears already quite usable (at least, to me).
2011-04-07 13:36
I think everyone loves primes. Well, at least most people do. I feel a bit nerdy, though, because I have the wonderful msieve integer factorizator installed on my computer and use it, well, mostly for fun and curiosity.

For testing it a bit more, and to get kind of an update on security considerations, I've hacked together a small program to generate large semiprimes (using OpenSSL, of course). For your semiprime-generation needs, its here:

Well, now for the product of a 120 bit prime with a 111 bit prime, 70-digit decimal number, msieve takes on my MacBook, well, about a single minute. That's kind of impressive to me. And shows how ridiculous 110 bits would be when used for asymmetric encryption.
2011-03-24 11:09
boost::asio provides a very convenient way of using SSL sockets. However, the information about the peer certificate provided is rather limited (read: non-existant) and there is only the option to either accept trusted certificates, or accept any certificate.

If you want to give feedback to the user and/or check the certificate digest (fingerprint), you have to resort to plain OpenSSL (given that OpenSSL is used as backend). For a ssl-socket, the following snipplet prints the issuer and fingerprints. Good idea would be to add a custom verification here as well.

Beware of very hackish code:

 1 #include <openssl/ssl.h>
 2 #include <openssl/x509.h>
 3 #include <openssl/evp.h>
 4 ...
 5 boost::asio::ssl::stream<boost::asio::ip::tcp::socket> ssl_socket_(io_service, ctx);
 6 ...
 7 bool connection::check_peer_certificate() {
 8 	// impl() provides access to the underlying SSL*
 9 	// struct from OpenSSL!
10 	SSL *ssl = ssl_socket_.impl()->ssl;
12 	// Use OpenSSL API do get what you desire
13 	X509 *cert = SSL_get_peer_certificate(ssl);
15 	printf("ISSUER: "); X509_NAME_print_ex_fp(stdout, X509_get_issuer_name(cert), 0, 0); printf("\n");
16 	printf("SUBJECT: "); X509_NAME_print_ex_fp(stdout, X509_get_subject_name(cert), 0, 0); printf("\n");
19 	unsigned int md5_size;
20 	unsigned char md5[EVP_MAX_MD_SIZE];
21 	X509_digest(cert, EVP_md5(), md5, &md5_size);
22 	printf("MD5: ");
23 	for(unsigned i=0; i<md5_size; ++i) printf("%02X ", md5[i]);
24 	printf("\n");
26 	unsigned int sha1_size;
27 	unsigned char sha1[EVP_MAX_MD_SIZE];
28 	X509_digest(cert, EVP_sha1(), sha1, &sha1_size);
29 	printf("SHA1: ");
30 	for(unsigned i=0; i<sha1_size; ++i) printf("%02X ", sha1[i]);
31 	printf("\n");
33 	X509_free(cert);
34 	// Better would be to validate cert, export fingerprints and
35 	// information so they can be presented to user and
36 	// return false if it does not validate ;)
37 	return true;
38 }
2011-03-16 14:27
OpenAL is a very powerful library for audio playback and recording. However, I just needed a minimal example on how to play a simple sine wave of a given frequency, synthesized by myself. This is basically quite easy using OpenAL as well. In a syntax similar to OpenGL, a buffer is generated and filled with samples (here a sine wave), which is then passed on to OpenAL for playback.

I've attached the sample code to this post. Now, this can be used to do fun stuff, like superimposing several sine (or, sawtooth!) waves, maybe add a LFO, some ASDR enveloping and build your own synthesizer from scratch. Though, if you like to code your sounds, you might want to take a look at ChucK, the audio programming language.

2011-03-10 10:34
I started to hack a very minimal SOCKS5 server in python using the twisted framework. Apparently, TCP/CONNECT works just fine, and that's all I wanted (BIND, UDP, Authentication are missing). This is the first time I did anything with twisted and I have to say that it is quite easy and convenient, although the documentation could need some improvements.

This hack could be used as a basis for further experiments. For instance, it might be more convenient to log network traffic using a SOCKS proxy instead of using a full network analyzer as e.g. Wireshark. Also, this might be used to insert or modify HTTP headers for HTTP requests or routing traffic through additional proxies, depending on intended destination.

Well, code is here but be aware that it's rather an example than anything else, including lack of good error handling and printing annoying information to stdout. On the other hand, it's just 128 lines ;-)
2011-03-09 14:06
Finally, I have changed my whole website. Everything is driven now by some custom code built on top of the totally awesome Django web framework. Everything still Python, but no longer any trac-abuse.

I had to migrate all old data manually, therefore I've just saved the blog posts I've considered worth saving. I did not restore any comments. And the Wiki is gone, which I did not use much anyways. If you are missing anything, please excuse the inconveniences. Also note that I am still working on the new site, so code is not perfect yet, maybe some dead links and stuff. Just wanted to switch as quickly as possible as the old site drowned in SPAM.

Speaking of spam, comments are now protected by Google's reCAPTCHA. Not the most secure solution out there, but I think it's acceptable and should suffice to stop spam on this site (or at least limit it to manual spam.)

older posts >>